
Database Testing
- 121 installs
- 433 repo stars
- Updated August 4, 2026
- proffesor-for-testing/agentic-qe
Validate migrations, constraints, transactions, and query correctness across relational or document stores, including seed data, rollback checks, and data integrity after schema changes.
About
Provides database testing guidance from the agentic-qe repository for verifying migrations, constraints, transactions, and data integrity, helping teams catch schema regressions and unsafe queries before they reach production workloads.
- Migration up/down verification
- Constraint and FK integrity tests
- Transaction and isolation scenarios
- Seed and fixture strategies
- Query performance smoke checks
Database Testing by the numbers
- 121 all-time installs (skills.sh)
- +4 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #943 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill database-testingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 121 |
|---|---|
| repo stars | ★ 433 |
| Last updated | August 4, 2026 |
| Repository | proffesor-for-testing/agentic-qe ↗ |
What it does
Validate migrations, constraints, transactions, and query correctness across relational or document stores, including seed data, rollback checks, and data integrity after schema changes.
Files
Database Testing
<default_to_action> When testing database operations: 1. VALIDATE schema (tables, columns, constraints exist as expected) 2. TEST data integrity (unique, foreign key, check constraints) 3. VERIFY migrations (forward works, rollback works, data preserved) 4. CHECK transaction isolation (ACID properties, concurrent access) 5. MEASURE query performance (indexes used, execution time)
Quick DB Testing Checklist:
- Schema matches specification
- Unique constraints prevent duplicates
- Foreign keys prevent orphaned records
- Migrations are reversible
- Transactions roll back on error
Critical Success Factors:
- Database bugs cause data loss/corruption (catastrophic)
- Test migrations in staging before production
- Transaction tests catch concurrency bugs
</default_to_action>
Quick Reference Card
When to Use
- New table/schema creation
- Migration development
- Data integrity validation
- Query performance optimization
Database Test Types
| Type | Focus | When |
|---|---|---|
| Schema | Structure correct | Table creation |
| Integrity | Constraints work | Data operations |
| Migration | Up/down work | Schema changes |
| Transaction | ACID properties | Concurrent access |
| Performance | Query speed | Optimization |
---
Schema Testing
test('users table has correct schema', async () => {
const schema = await db.raw(`
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'users'
`);
expect(schema).toContainEqual({
column_name: 'id',
data_type: 'integer',
is_nullable: 'NO'
});
expect(schema).toContainEqual({
column_name: 'email',
data_type: 'character varying',
is_nullable: 'NO'
});
});---
Data Integrity Testing
test('email must be unique', async () => {
await db.users.create({ email: 'test@example.com' });
await expect(
db.users.create({ email: 'test@example.com' })
).rejects.toThrow('unique constraint violation');
});
test('foreign key prevents orphaned records', async () => {
const user = await db.users.create({ email: 'test@example.com' });
await db.orders.create({ userId: user.id, total: 100 });
await expect(
db.users.delete({ id: user.id })
).rejects.toThrow('foreign key constraint');
});---
Migration Testing
test('migration is reversible', async () => {
await migrate('add-users-table');
// Table exists after migration
const tables = await db.raw(`SELECT table_name FROM information_schema.tables`);
expect(tables.map(t => t.table_name)).toContain('users');
await rollback('add-users-table');
// Table gone after rollback
const tablesAfter = await db.raw(`SELECT table_name FROM information_schema.tables`);
expect(tablesAfter.map(t => t.table_name)).not.toContain('users');
});
test('migration preserves existing data', async () => {
await db.users.create({ email: 'test@example.com' });
await migrate('add-age-column');
const user = await db.users.findOne({ email: 'test@example.com' });
expect(user).toBeDefined();
expect(user.age).toBeNull(); // New column, null default
});---
Transaction Testing
test('transaction rolls back on error', async () => {
const initialCount = await db.users.count();
try {
await db.transaction(async (trx) => {
await trx('users').insert({ email: 'user1@example.com' });
await trx('users').insert({ email: 'user2@example.com' });
throw new Error('Rollback test');
});
} catch (error) { /* Expected */ }
expect(await db.users.count()).toBe(initialCount);
});
test('concurrent transactions isolated', async () => {
const user = await db.users.create({ balance: 100 });
// Two concurrent withdrawals (race condition test)
await Promise.all([
db.transaction(async (trx) => {
const current = await trx('users').where({ id: user.id }).first();
await trx('users').update({ balance: current.balance - 50 });
}),
db.transaction(async (trx) => {
const current = await trx('users').where({ id: user.id }).first();
await trx('users').update({ balance: current.balance - 50 });
})
]);
const final = await db.users.findOne({ id: user.id });
expect(final.balance).toBe(0); // Proper isolation
});---
Agent-Driven Database Testing
// Generate test data with integrity
await Task("Generate Test Data", {
schema: 'ecommerce',
tables: ['users', 'products', 'orders'],
count: { users: 1000, products: 500, orders: 5000 },
preserveReferentialIntegrity: true
}, "qe-test-data-architect");
// Test migration safety
await Task("Migration Test", {
migration: 'add-payment-status-column',
tests: ['forward', 'rollback', 'data-preservation'],
environment: 'staging'
}, "qe-test-executor");---
Agent Coordination Hints
Memory Namespace
aqe/database-testing/
├── schema-snapshots/* - Current schema state
├── migrations/* - Migration test results
├── integrity/* - Constraint validation
└── performance/* - Query benchmarksFleet Coordination
const dbFleet = await FleetManager.coordinate({
strategy: 'database-testing',
agents: [
'qe-test-data-architect', // Generate test data
'qe-test-executor', // Run DB tests
'qe-performance-tester' // Query performance
],
topology: 'sequential'
});---
Related Skills
- test-data-management - Generate test data
- performance-testing - Query performance
- compliance-testing - Data protection
---
Remember
Test migrations before production: Forward works, rollback works, data preserved, performance acceptable. Never deploy untested migrations.
With Agents: qe-test-data-architect generates realistic test data with referential integrity. qe-test-executor validates migrations automatically in CI/CD.
# =============================================================================
# AQE Skill Evaluation Test Suite: Database Testing v1.0.0
# =============================================================================
#
# Comprehensive evaluation suite for the database-testing skill per ADR-056.
# Tests schema validation, data integrity, migration testing, transaction ACID
# properties, and query performance analysis across multiple database types.
#
# Schema: .claude/skills/.validation/schemas/skill-eval.schema.json
# Validator: .claude/skills/database-testing/scripts/validate-config.json
#
# Coverage:
# - Schema validation (tables, columns, constraints, indexes)
# - Data integrity (unique, foreign key, check constraints)
# - Migration testing (forward, rollback, data preservation)
# - Transaction testing (ACID properties, isolation levels)
# - Query performance (slow queries, missing indexes, N+1)
# - Multi-database support (PostgreSQL, MySQL, MongoDB, SQLite)
#
# =============================================================================
skill: database-testing
version: 1.0.0
description: >
Comprehensive evaluation suite for the database-testing skill.
Tests database schema validation, data integrity verification,
migration testing, transaction ACID compliance, and query performance
analysis. Supports PostgreSQL, MySQL, MongoDB, and SQLite.
Integrates with ReasoningBank for continuous improvement.
# =============================================================================
# Multi-Model Configuration
# =============================================================================
models_to_test:
- claude-sonnet-4-6 # Primary (high accuracy expected)
- claude-haiku-4-5 # Fast model (minimum quality floor)
# =============================================================================
# MCP Integration Configuration
# =============================================================================
mcp_integration:
enabled: true
namespace: skill-validation
# Query existing database patterns before running evals
query_patterns: true
# Track each test outcome for learning feedback loop
track_outcomes: true
# Store successful patterns after evals complete
store_patterns: true
# Share learning with fleet coordinator agents
share_learning: true
# Update quality gate with validation metrics
update_quality_gate: true
# Target agents for learning distribution
target_agents:
- qe-learning-coordinator
- qe-queen-coordinator
- qe-test-data-architect
- qe-test-executor
- qe-performance-tester
# =============================================================================
# ReasoningBank Learning Configuration
# =============================================================================
learning:
store_success_patterns: true
store_failure_patterns: true
pattern_ttl_days: 90
min_confidence_to_store: 0.7
cross_model_comparison: true
# =============================================================================
# Result Format Configuration
# =============================================================================
result_format:
json_output: true
markdown_report: true
include_raw_output: false
include_timing: true
include_token_usage: true
# =============================================================================
# Environment Setup
# =============================================================================
setup:
required_tools:
- jq # JSON parsing (required)
- node # ORM validation (optional but recommended)
environment_variables:
DATABASE_TEST_DEPTH: "comprehensive"
MIGRATION_TEST_ROLLBACK: "true"
ACID_TEST_ENABLED: "true"
fixtures:
- name: postgresql_schema_test
path: fixtures/postgresql-schema.sql
content: |
-- PostgreSQL test schema with intentional issues
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255), -- Missing UNIQUE constraint
password VARCHAR(255), -- Should be NOT NULL
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER, -- Missing FOREIGN KEY
total DECIMAL(10,2),
status VARCHAR(50)
);
-- Missing index on frequently queried column
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
category VARCHAR(100),
price DECIMAL(10,2)
);
- name: migration_test_file
path: fixtures/migration-add-age.js
content: |
exports.up = async function(knex) {
await knex.schema.alterTable('users', (table) => {
table.integer('age').nullable();
});
};
exports.down = async function(knex) {
await knex.schema.alterTable('users', (table) => {
table.dropColumn('age');
});
};
# =============================================================================
# TEST CASES
# =============================================================================
test_cases:
# ---------------------------------------------------------------------------
# CATEGORY: Schema Validation
# ---------------------------------------------------------------------------
- id: tc001_missing_unique_constraint
description: "Detect missing UNIQUE constraint on email column"
category: schema
priority: critical
input:
code: |
-- User table without unique email constraint
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255),
name VARCHAR(100),
created_at TIMESTAMP DEFAULT NOW()
);
-- Application code that assumes email uniqueness
INSERT INTO users (email, name) VALUES ('john@example.com', 'John');
INSERT INTO users (email, name) VALUES ('john@example.com', 'Johnny'); -- Duplicate allowed!
context:
database: postgresql
framework: knex
environment: production
expected_output:
must_contain:
- "unique"
- "constraint"
- "email"
- "duplicate"
must_not_contain:
- "no issues"
- "valid schema"
must_match_regex:
- "DB-\\d{3}"
severity_classification: high
finding_count:
min: 1
max: 5
validation:
schema_check: true
keyword_match_threshold: 0.8
reasoning_quality_min: 0.7
grading_rubric:
completeness: 0.3
accuracy: 0.5
actionability: 0.2
timeout_ms: 30000
- id: tc002_missing_foreign_key
description: "Detect missing foreign key constraint causing orphaned records"
category: schema
priority: critical
input:
code: |
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER, -- No FK constraint!
total DECIMAL(10,2)
);
-- This allows orphaned orders
INSERT INTO orders (user_id, total) VALUES (999, 100.00);
DELETE FROM users WHERE id = 1; -- Orphans all orders for user 1
context:
database: postgresql
framework: prisma
expected_output:
must_contain:
- "foreign key"
- "referential integrity"
- "orphaned"
must_match_regex:
- "DB-\\d{3}"
severity_classification: critical
finding_count:
min: 1
validation:
schema_check: true
keyword_match_threshold: 0.8
- id: tc003_missing_index_on_foreign_key
description: "Detect missing index on foreign key column affecting performance"
category: schema
priority: high
input:
code: |
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
product_id INTEGER REFERENCES products(id),
quantity INTEGER,
created_at TIMESTAMP
);
-- Frequently run queries without indexes
SELECT * FROM orders WHERE user_id = 123;
SELECT COUNT(*) FROM orders WHERE product_id = 456;
context:
database: postgresql
framework: typeorm
expected_output:
must_contain:
- "index"
- "foreign key"
- "performance"
- "user_id"
must_match_regex:
- "CREATE INDEX"
severity_classification: medium
validation:
schema_check: true
keyword_match_threshold: 0.7
# ---------------------------------------------------------------------------
# CATEGORY: Data Integrity
# ---------------------------------------------------------------------------
- id: tc004_check_constraint_violation
description: "Detect check constraint violations on status column"
category: integrity
priority: high
input:
code: |
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
status VARCHAR(20) CHECK (status IN ('pending', 'processing', 'shipped', 'delivered')),
total DECIMAL(10,2) CHECK (total >= 0)
);
-- Test constraint enforcement
INSERT INTO orders (status, total) VALUES ('invalid_status', 100.00);
INSERT INTO orders (status, total) VALUES ('pending', -50.00);
context:
database: postgresql
test_type: integrity
expected_output:
must_contain:
- "check constraint"
- "violation"
- "status"
must_not_contain:
- "passed"
- "valid"
severity_classification: high
validation:
schema_check: true
keyword_match_threshold: 0.8
- id: tc005_null_constraint_test
description: "Detect NOT NULL constraint violations"
category: integrity
priority: high
input:
code: |
const user = new User();
user.email = 'test@example.com';
// Missing required field: password
await user.save();
// Schema:
// email VARCHAR(255) NOT NULL
// password VARCHAR(255) NOT NULL
// name VARCHAR(100) -- nullable
context:
database: mysql
framework: sequelize
test_type: integrity
expected_output:
must_contain:
- "NOT NULL"
- "constraint"
- "password"
- "required"
severity_classification: high
finding_count:
min: 1
validation:
schema_check: true
keyword_match_threshold: 0.8
# ---------------------------------------------------------------------------
# CATEGORY: Migration Testing
# ---------------------------------------------------------------------------
- id: tc006_migration_forward_test
description: "Test migration applies successfully forward"
category: migration
priority: critical
input:
code: |
// Migration: add-user-roles.js
exports.up = async function(knex) {
await knex.schema.createTable('roles', (table) => {
table.increments('id');
table.string('name').unique().notNullable();
});
await knex.schema.alterTable('users', (table) => {
table.integer('role_id').references('id').inTable('roles');
});
};
exports.down = async function(knex) {
await knex.schema.alterTable('users', (table) => {
table.dropColumn('role_id');
});
await knex.schema.dropTable('roles');
};
context:
database: postgresql
framework: knex
test_type: migration
expected_output:
must_contain:
- "migration"
- "forward"
- "roles"
- "users"
must_not_contain:
- "failed"
- "error"
must_match_regex:
- "up|forward|apply"
validation:
schema_check: true
keyword_match_threshold: 0.7
- id: tc007_migration_rollback_test
description: "Test migration rollback works correctly"
category: migration
priority: critical
input:
code: |
// Test migration rollback
await migrate.latest(); // Apply all migrations
await migrate.rollback(); // Rollback last batch
// Verify tables are removed
const tables = await knex.raw("SELECT table_name FROM information_schema.tables");
expect(tables).not.toContain('new_feature_table');
context:
database: postgresql
framework: knex
test_type: migration
expected_output:
must_contain:
- "rollback"
- "down"
- "reverse"
must_not_contain:
- "irreversible"
- "failed"
severity_classification: medium
validation:
schema_check: true
keyword_match_threshold: 0.7
- id: tc008_migration_data_preservation
description: "Test migration preserves existing data"
category: migration
priority: critical
input:
code: |
// Existing data before migration
await db.users.create({ email: 'existing@example.com', name: 'Existing User' });
// Migration adds new column
exports.up = async function(knex) {
await knex.schema.alterTable('users', (table) => {
table.string('phone').nullable();
});
};
// After migration, verify existing data is preserved
const user = await db.users.findOne({ email: 'existing@example.com' });
expect(user.name).toBe('Existing User'); // Data should be intact
expect(user.phone).toBeNull(); // New column should be null
context:
database: postgresql
framework: knex
test_type: migration
expected_output:
must_contain:
- "data preservation"
- "existing"
- "intact"
- "backward compatible"
must_not_contain:
- "data loss"
- "corrupted"
severity_classification: critical
validation:
schema_check: true
keyword_match_threshold: 0.7
# ---------------------------------------------------------------------------
# CATEGORY: Transaction Testing (ACID)
# ---------------------------------------------------------------------------
- id: tc009_atomicity_test
description: "Test transaction atomicity - all or nothing"
category: transaction
priority: critical
input:
code: |
test('transaction rolls back on error', async () => {
const initialCount = await db.users.count();
try {
await db.transaction(async (trx) => {
await trx('users').insert({ email: 'user1@example.com' });
await trx('users').insert({ email: 'user2@example.com' });
throw new Error('Intentional rollback');
});
} catch (error) { /* Expected */ }
// Count should be unchanged
expect(await db.users.count()).toBe(initialCount);
});
context:
database: postgresql
framework: knex
test_type: transaction
expected_output:
must_contain:
- "atomicity"
- "rollback"
- "transaction"
- "all or nothing"
must_not_contain:
- "partial commit"
must_match_regex:
- "ACID|atomic"
severity_classification: critical
validation:
schema_check: true
keyword_match_threshold: 0.8
reasoning_quality_min: 0.8
- id: tc010_isolation_test
description: "Test transaction isolation - concurrent access"
category: transaction
priority: critical
input:
code: |
test('concurrent transactions isolated', async () => {
const user = await db.users.create({ balance: 100 });
// Two concurrent withdrawals - race condition test
const results = await Promise.all([
db.transaction(async (trx) => {
const current = await trx('users').where({ id: user.id }).first();
if (current.balance >= 50) {
await trx('users').where({ id: user.id }).update({
balance: current.balance - 50
});
return 'success';
}
return 'insufficient';
}),
db.transaction(async (trx) => {
const current = await trx('users').where({ id: user.id }).first();
if (current.balance >= 50) {
await trx('users').where({ id: user.id }).update({
balance: current.balance - 50
});
return 'success';
}
return 'insufficient';
})
]);
const final = await db.users.findOne({ id: user.id });
// With proper isolation, one should fail or balance should be 0
expect(final.balance).toBeGreaterThanOrEqual(0);
});
context:
database: postgresql
framework: knex
test_type: transaction
isolation_level: REPEATABLE_READ
expected_output:
must_contain:
- "isolation"
- "concurrent"
- "race condition"
- "lock"
must_match_regex:
- "READ_COMMITTED|REPEATABLE_READ|SERIALIZABLE"
severity_classification: critical
validation:
schema_check: true
keyword_match_threshold: 0.7
- id: tc011_deadlock_detection
description: "Test deadlock detection and resolution"
category: transaction
priority: high
input:
code: |
test('deadlock is detected and handled', async () => {
// Create potential deadlock scenario
const tx1 = db.transaction(async (trx) => {
await trx('accounts').where({ id: 1 }).update({ balance: 100 });
await delay(100);
await trx('accounts').where({ id: 2 }).update({ balance: 200 });
});
const tx2 = db.transaction(async (trx) => {
await trx('accounts').where({ id: 2 }).update({ balance: 150 });
await delay(100);
await trx('accounts').where({ id: 1 }).update({ balance: 250 });
});
// One should fail with deadlock, other should succeed
const results = await Promise.allSettled([tx1, tx2]);
const failures = results.filter(r => r.status === 'rejected');
expect(failures.some(f => f.reason.message.includes('deadlock'))).toBe(true);
});
context:
database: postgresql
framework: knex
test_type: transaction
expected_output:
must_contain:
- "deadlock"
- "detection"
- "retry"
- "conflict"
severity_classification: high
validation:
schema_check: true
keyword_match_threshold: 0.7
# ---------------------------------------------------------------------------
# CATEGORY: Performance Testing
# ---------------------------------------------------------------------------
- id: tc012_slow_query_detection
description: "Detect slow queries without proper indexing"
category: performance
priority: high
input:
code: |
-- Slow query: full table scan on large table
SELECT * FROM orders
WHERE created_at BETWEEN '2024-01-01' AND '2024-12-31'
AND status = 'pending';
-- Table has 10 million rows, no index on created_at or status
EXPLAIN ANALYZE SELECT * FROM orders
WHERE created_at BETWEEN '2024-01-01' AND '2024-12-31';
-- Output: Seq Scan on orders (cost=0.00..250000.00 rows=5000000)
context:
database: postgresql
test_type: performance
table_size: 10000000
expected_output:
must_contain:
- "slow query"
- "full table scan"
- "index"
- "Seq Scan"
must_match_regex:
- "CREATE INDEX"
severity_classification: high
finding_count:
min: 1
validation:
schema_check: true
keyword_match_threshold: 0.8
- id: tc013_n_plus_one_detection
description: "Detect N+1 query problem"
category: performance
priority: high
input:
code: |
// N+1 query problem
const users = await User.findAll(); // 1 query
for (const user of users) {
const orders = await Order.findAll({
where: { userId: user.id }
}); // N queries!
user.orderCount = orders.length;
}
// Should be:
// const users = await User.findAll({
// include: [{ model: Order }]
// });
context:
database: postgresql
framework: sequelize
test_type: performance
expected_output:
must_contain:
- "N+1"
- "query"
- "include"
- "eager loading"
- "join"
must_not_contain:
- "efficient"
- "optimal"
severity_classification: high
validation:
schema_check: true
keyword_match_threshold: 0.8
- id: tc014_connection_pool_exhaustion
description: "Detect connection pool exhaustion risk"
category: performance
priority: critical
input:
code: |
// Connection leak - connections not released
async function getUserData(userId) {
const connection = await pool.getConnection();
const user = await connection.query('SELECT * FROM users WHERE id = ?', [userId]);
// Missing: connection.release()
return user;
}
// Called in a loop without releasing connections
for (let i = 0; i < 1000; i++) {
await getUserData(i);
}
context:
database: mysql
framework: mysql2
test_type: performance
pool_size: 10
expected_output:
must_contain:
- "connection"
- "pool"
- "leak"
- "release"
- "exhaustion"
severity_classification: critical
validation:
schema_check: true
keyword_match_threshold: 0.8
# ---------------------------------------------------------------------------
# CATEGORY: Multi-Database Support
# ---------------------------------------------------------------------------
- id: tc015_mongodb_schema_validation
description: "Test MongoDB schema validation"
category: schema
priority: high
input:
code: |
// MongoDB collection without schema validation
db.createCollection("users");
// Can insert inconsistent documents
db.users.insertOne({ email: "user@example.com", age: 25 });
db.users.insertOne({ email: 123, age: "twenty" }); // Wrong types!
db.users.insertOne({ name: "John" }); // Missing email
// Should have JSON Schema validation:
db.createCollection("users", {
validator: {
$jsonSchema: {
bsonType: "object",
required: ["email"],
properties: {
email: { bsonType: "string" },
age: { bsonType: "int" }
}
}
}
});
context:
database: mongodb
test_type: schema
expected_output:
must_contain:
- "schema validation"
- "MongoDB"
- "jsonSchema"
- "bsonType"
severity_classification: high
validation:
schema_check: true
keyword_match_threshold: 0.7
- id: tc016_sqlite_foreign_key_enforcement
description: "Test SQLite foreign key enforcement"
category: integrity
priority: high
input:
code: |
-- SQLite: Foreign keys are OFF by default!
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE orders (
id INTEGER PRIMARY KEY,
user_id INTEGER REFERENCES users(id)
);
-- This succeeds even though user 999 doesn't exist
INSERT INTO orders (user_id) VALUES (999);
-- Need to enable: PRAGMA foreign_keys = ON;
context:
database: sqlite
test_type: integrity
expected_output:
must_contain:
- "foreign_keys"
- "PRAGMA"
- "SQLite"
- "enforcement"
must_match_regex:
- "PRAGMA foreign_keys\\s*=\\s*ON"
severity_classification: high
validation:
schema_check: true
keyword_match_threshold: 0.8
# ---------------------------------------------------------------------------
# CATEGORY: Negative Tests (Secure/Valid Code)
# ---------------------------------------------------------------------------
- id: tc017_valid_schema_no_false_positives
description: "Verify well-designed schema is NOT flagged as problematic"
category: negative
priority: critical
input:
code: |
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE orders (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
total DECIMAL(10,2) NOT NULL CHECK (total >= 0),
status VARCHAR(20) NOT NULL DEFAULT 'pending'
CHECK (status IN ('pending', 'processing', 'shipped', 'delivered', 'cancelled')),
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE INDEX idx_orders_status ON orders(status);
CREATE INDEX idx_orders_created_at ON orders(created_at);
context:
database: postgresql
framework: prisma
environment: production
expected_output:
must_contain:
- "valid"
- "well-designed"
- "proper constraints"
must_not_contain:
- "missing constraint"
- "critical"
- "high severity"
- "orphaned"
finding_count:
max: 2 # Allow informational findings only
validation:
schema_check: true
keyword_match_threshold: 0.6
allow_partial: true
- id: tc018_proper_migration_pattern
description: "Verify proper migration pattern is recognized"
category: negative
priority: high
input:
code: |
// Proper reversible migration with data preservation
exports.up = async function(knex) {
// Check if column exists before adding
const hasColumn = await knex.schema.hasColumn('users', 'phone');
if (!hasColumn) {
await knex.schema.alterTable('users', (table) => {
table.string('phone').nullable();
});
}
};
exports.down = async function(knex) {
const hasColumn = await knex.schema.hasColumn('users', 'phone');
if (hasColumn) {
await knex.schema.alterTable('users', (table) => {
table.dropColumn('phone');
});
}
};
context:
database: postgresql
framework: knex
test_type: migration
expected_output:
must_contain:
- "reversible"
- "idempotent"
- "safe"
must_not_contain:
- "irreversible"
- "data loss"
- "critical"
severity_classification: info
validation:
schema_check: true
allow_partial: true
# =============================================================================
# SUCCESS CRITERIA
# =============================================================================
success_criteria:
# Overall pass rate (90% of tests must pass)
pass_rate: 0.9
# Critical tests must ALL pass (100%)
critical_pass_rate: 1.0
# Average reasoning quality score
avg_reasoning_quality: 0.75
# Maximum suite execution time (5 minutes)
max_execution_time_ms: 300000
# Maximum variance between model results (15%)
cross_model_variance: 0.15
# =============================================================================
# METADATA
# =============================================================================
metadata:
author: "qe-test-data-architect"
created: "2026-02-02"
last_updated: "2026-02-02"
coverage_target: >
Database testing coverage: Schema validation (missing constraints, indexes),
Data integrity (unique, FK, check, NOT NULL), Migration testing (forward,
rollback, data preservation), Transaction testing (ACID: atomicity, isolation,
deadlock), Performance (slow queries, N+1, connection pools). Multi-database
support: PostgreSQL, MySQL, MongoDB, SQLite. 18 test cases with 90% pass rate
requirement and 100% critical pass rate for ACID and migration tests.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://agentic-qe.dev/schemas/database-testing-output.json",
"title": "AQE Database Testing Skill Output Schema",
"description": "Schema for database-testing skill output validation. Extends the base skill-output template with schema validation, data integrity testing, migration verification, transaction testing, and query performance analysis.",
"type": "object",
"required": ["skillName", "version", "timestamp", "status", "trustTier", "output"],
"properties": {
"skillName": {
"type": "string",
"const": "database-testing",
"description": "Must be 'database-testing'"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)?$",
"description": "Semantic version of the skill"
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "ISO 8601 timestamp of output generation"
},
"status": {
"type": "string",
"enum": ["success", "partial", "failed", "skipped"],
"description": "Overall execution status"
},
"trustTier": {
"type": "integer",
"const": 3,
"description": "Trust tier 3 indicates full validation with eval suite"
},
"output": {
"type": "object",
"required": ["summary", "findings", "testTypes", "databaseInfo"],
"properties": {
"summary": {
"type": "string",
"minLength": 50,
"maxLength": 2000,
"description": "Human-readable summary of database testing findings"
},
"score": {
"$ref": "#/$defs/databaseScore",
"description": "Overall database quality score"
},
"findings": {
"type": "array",
"items": {
"$ref": "#/$defs/databaseFinding"
},
"maxItems": 500,
"description": "List of database issues discovered"
},
"recommendations": {
"type": "array",
"items": {
"$ref": "#/$defs/databaseRecommendation"
},
"maxItems": 100,
"description": "Prioritized recommendations for database improvements"
},
"metrics": {
"$ref": "#/$defs/databaseMetrics",
"description": "Database testing metrics and statistics"
},
"testTypes": {
"$ref": "#/$defs/testTypeBreakdown",
"description": "Breakdown by database test type"
},
"databaseInfo": {
"$ref": "#/$defs/databaseInfo",
"description": "Target database information"
},
"schemaValidation": {
"$ref": "#/$defs/schemaValidation",
"description": "Schema validation results"
},
"dataIntegrity": {
"$ref": "#/$defs/dataIntegrity",
"description": "Data integrity test results"
},
"migrationTests": {
"$ref": "#/$defs/migrationTests",
"description": "Migration test results"
},
"transactionTests": {
"$ref": "#/$defs/transactionTests",
"description": "Transaction/ACID test results"
},
"performanceTests": {
"$ref": "#/$defs/performanceTests",
"description": "Query performance test results"
},
"artifacts": {
"type": "array",
"items": {
"$ref": "#/$defs/artifact"
},
"maxItems": 50,
"description": "Generated test reports and artifacts"
},
"timeline": {
"type": "array",
"items": {
"$ref": "#/$defs/timelineEvent"
},
"description": "Test execution timeline"
}
}
},
"metadata": {
"$ref": "#/$defs/metadata"
},
"validation": {
"$ref": "#/$defs/validationResult"
},
"learning": {
"$ref": "#/$defs/learningData"
}
},
"$defs": {
"databaseScore": {
"type": "object",
"required": ["value", "max"],
"properties": {
"value": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Database quality score (0=critical issues, 100=excellent)"
},
"max": {
"type": "number",
"const": 100,
"description": "Maximum score is always 100"
},
"grade": {
"type": "string",
"pattern": "^[A-F][+-]?$",
"description": "Letter grade: A (90-100), B (80-89), C (70-79), D (60-69), F (<60)"
},
"trend": {
"type": "string",
"enum": ["improving", "stable", "declining", "unknown"],
"description": "Trend compared to previous assessments"
},
"dataQualityLevel": {
"type": "string",
"enum": ["excellent", "good", "fair", "poor", "critical"],
"description": "Overall data quality assessment"
}
}
},
"databaseFinding": {
"type": "object",
"required": ["id", "title", "severity", "testType"],
"properties": {
"id": {
"type": "string",
"pattern": "^DB-\\d{3,6}$",
"description": "Unique finding identifier (e.g., DB-001)"
},
"title": {
"type": "string",
"minLength": 10,
"maxLength": 200,
"description": "Finding title describing the database issue"
},
"description": {
"type": "string",
"maxLength": 2000,
"description": "Detailed description of the database issue"
},
"severity": {
"type": "string",
"enum": ["critical", "high", "medium", "low", "info"],
"description": "Severity: critical=data loss risk, high=integrity risk, medium=performance, low=improvement, info=informational"
},
"testType": {
"type": "string",
"enum": ["schema", "integrity", "migration", "transaction", "performance", "data-quality"],
"description": "Category of database test that found this issue"
},
"category": {
"type": "string",
"enum": [
"missing-constraint",
"orphaned-records",
"constraint-violation",
"schema-mismatch",
"migration-failure",
"migration-rollback-failure",
"data-loss",
"transaction-isolation",
"deadlock",
"slow-query",
"missing-index",
"n-plus-one",
"connection-leak",
"data-corruption",
"referential-integrity",
"null-violation",
"type-mismatch",
"encoding-issue"
],
"description": "Specific category of database issue"
},
"location": {
"$ref": "#/$defs/databaseLocation",
"description": "Location of the issue in the database"
},
"evidence": {
"type": "string",
"maxLength": 5000,
"description": "Evidence: SQL query, error message, data sample"
},
"remediation": {
"type": "string",
"maxLength": 2000,
"description": "Specific fix instructions for this finding"
},
"sqlFix": {
"type": "string",
"maxLength": 2000,
"description": "SQL statement to fix the issue"
},
"affectedRows": {
"type": "integer",
"minimum": 0,
"description": "Number of rows affected by this issue"
},
"affectedTables": {
"type": "array",
"items": { "type": "string" },
"description": "Tables affected by this issue"
},
"falsePositive": {
"type": "boolean",
"default": false,
"description": "Potential false positive flag"
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Confidence in finding accuracy (0.0-1.0)"
},
"dataImpact": {
"type": "string",
"enum": ["none", "low", "medium", "high", "critical"],
"description": "Potential data impact if not fixed"
}
}
},
"databaseRecommendation": {
"type": "object",
"required": ["id", "title", "priority", "testType"],
"properties": {
"id": {
"type": "string",
"pattern": "^REC-\\d{3,6}$",
"description": "Unique recommendation identifier"
},
"title": {
"type": "string",
"minLength": 10,
"maxLength": 200,
"description": "Recommendation title"
},
"description": {
"type": "string",
"maxLength": 2000,
"description": "Detailed recommendation description"
},
"priority": {
"type": "string",
"enum": ["critical", "high", "medium", "low"],
"description": "Remediation priority"
},
"effort": {
"type": "string",
"enum": ["trivial", "low", "medium", "high", "major"],
"description": "Estimated effort"
},
"impact": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"description": "Database quality impact if implemented (1-10)"
},
"relatedFindings": {
"type": "array",
"items": {
"type": "string",
"pattern": "^DB-\\d{3,6}$"
},
"description": "IDs of findings this addresses"
},
"testType": {
"type": "string",
"enum": ["schema", "integrity", "migration", "transaction", "performance", "data-quality"],
"description": "Related test type"
},
"sqlExample": {
"type": "object",
"properties": {
"before": {
"type": "string",
"maxLength": 2000,
"description": "Problematic SQL/schema"
},
"after": {
"type": "string",
"maxLength": 2000,
"description": "Recommended SQL/schema"
},
"migration": {
"type": "string",
"maxLength": 2000,
"description": "Migration SQL to apply fix"
}
},
"description": "SQL examples for remediation"
},
"resources": {
"type": "array",
"items": {
"type": "object",
"required": ["title", "url"],
"properties": {
"title": { "type": "string" },
"url": { "type": "string", "format": "uri" }
}
},
"maxItems": 10,
"description": "External resources and documentation"
},
"automatable": {
"type": "boolean",
"description": "Can this fix be automated via migration?"
}
}
},
"testTypeBreakdown": {
"type": "object",
"description": "Database test type breakdown",
"properties": {
"schema": {
"$ref": "#/$defs/testTypeScore",
"description": "Schema validation tests"
},
"integrity": {
"$ref": "#/$defs/testTypeScore",
"description": "Data integrity tests"
},
"migration": {
"$ref": "#/$defs/testTypeScore",
"description": "Migration tests"
},
"transaction": {
"$ref": "#/$defs/testTypeScore",
"description": "Transaction/ACID tests"
},
"performance": {
"$ref": "#/$defs/testTypeScore",
"description": "Query performance tests"
},
"dataQuality": {
"$ref": "#/$defs/testTypeScore",
"description": "Data quality tests"
}
},
"additionalProperties": false
},
"testTypeScore": {
"type": "object",
"required": ["tested", "score"],
"properties": {
"tested": {
"type": "boolean",
"description": "Whether this test type was executed"
},
"score": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Test type score (100 = all passed, 0 = all failed)"
},
"grade": {
"type": "string",
"pattern": "^[A-F][+-]?$",
"description": "Letter grade for this test type"
},
"findingCount": {
"type": "integer",
"minimum": 0,
"description": "Number of findings in this category"
},
"passedTests": {
"type": "integer",
"minimum": 0,
"description": "Number of tests passed"
},
"failedTests": {
"type": "integer",
"minimum": 0,
"description": "Number of tests failed"
},
"skippedTests": {
"type": "integer",
"minimum": 0,
"description": "Number of tests skipped"
},
"status": {
"type": "string",
"enum": ["pass", "fail", "warn", "skip"],
"description": "Overall status for this test type"
}
}
},
"databaseInfo": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"enum": ["postgresql", "mysql", "mariadb", "mongodb", "sqlite", "mssql", "oracle", "redis", "cassandra", "other"],
"description": "Database engine type"
},
"version": {
"type": "string",
"description": "Database version"
},
"name": {
"type": "string",
"description": "Database name"
},
"host": {
"type": "string",
"description": "Database host (masked for security)"
},
"schemaCount": {
"type": "integer",
"minimum": 0,
"description": "Number of schemas analyzed"
},
"tableCount": {
"type": "integer",
"minimum": 0,
"description": "Number of tables analyzed"
},
"totalRows": {
"type": "integer",
"minimum": 0,
"description": "Total rows in database"
},
"sizeBytes": {
"type": "integer",
"minimum": 0,
"description": "Database size in bytes"
},
"connectionPool": {
"type": "object",
"properties": {
"min": { "type": "integer" },
"max": { "type": "integer" },
"current": { "type": "integer" }
},
"description": "Connection pool settings"
}
}
},
"schemaValidation": {
"type": "object",
"description": "Schema validation results",
"properties": {
"tablesValidated": {
"type": "integer",
"minimum": 0,
"description": "Number of tables validated"
},
"columnsValidated": {
"type": "integer",
"minimum": 0,
"description": "Number of columns validated"
},
"tables": {
"type": "array",
"items": {
"$ref": "#/$defs/tableValidation"
},
"description": "Per-table validation results"
},
"missingTables": {
"type": "array",
"items": { "type": "string" },
"description": "Tables that should exist but don't"
},
"extraTables": {
"type": "array",
"items": { "type": "string" },
"description": "Tables that exist but shouldn't"
},
"constraintIssues": {
"type": "array",
"items": {
"$ref": "#/$defs/constraintIssue"
},
"description": "Constraint-related issues"
},
"indexIssues": {
"type": "array",
"items": {
"$ref": "#/$defs/indexIssue"
},
"description": "Index-related issues"
}
}
},
"tableValidation": {
"type": "object",
"required": ["name", "status"],
"properties": {
"name": {
"type": "string",
"description": "Table name"
},
"status": {
"type": "string",
"enum": ["valid", "invalid", "warning"],
"description": "Validation status"
},
"columns": {
"type": "array",
"items": {
"$ref": "#/$defs/columnValidation"
},
"description": "Column validation results"
},
"primaryKey": {
"type": "object",
"properties": {
"exists": { "type": "boolean" },
"columns": {
"type": "array",
"items": { "type": "string" }
}
},
"description": "Primary key validation"
},
"foreignKeys": {
"type": "array",
"items": {
"$ref": "#/$defs/foreignKeyValidation"
},
"description": "Foreign key validations"
},
"indexes": {
"type": "array",
"items": {
"$ref": "#/$defs/indexValidation"
},
"description": "Index validations"
},
"rowCount": {
"type": "integer",
"minimum": 0,
"description": "Number of rows in table"
}
}
},
"columnValidation": {
"type": "object",
"required": ["name", "dataType"],
"properties": {
"name": {
"type": "string",
"description": "Column name"
},
"dataType": {
"type": "string",
"description": "Column data type"
},
"expectedType": {
"type": "string",
"description": "Expected data type (if different)"
},
"nullable": {
"type": "boolean",
"description": "Whether column allows NULL"
},
"hasDefault": {
"type": "boolean",
"description": "Whether column has a default value"
},
"defaultValue": {
"description": "Default value"
},
"issues": {
"type": "array",
"items": { "type": "string" },
"description": "Issues with this column"
}
}
},
"foreignKeyValidation": {
"type": "object",
"required": ["name", "referencedTable"],
"properties": {
"name": {
"type": "string",
"description": "Foreign key constraint name"
},
"columns": {
"type": "array",
"items": { "type": "string" },
"description": "Local columns"
},
"referencedTable": {
"type": "string",
"description": "Referenced table name"
},
"referencedColumns": {
"type": "array",
"items": { "type": "string" },
"description": "Referenced columns"
},
"onDelete": {
"type": "string",
"enum": ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"],
"description": "ON DELETE action"
},
"onUpdate": {
"type": "string",
"enum": ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"],
"description": "ON UPDATE action"
},
"valid": {
"type": "boolean",
"description": "Whether FK is valid"
},
"orphanedRecords": {
"type": "integer",
"minimum": 0,
"description": "Number of orphaned records found"
}
}
},
"indexValidation": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"description": "Index name"
},
"columns": {
"type": "array",
"items": { "type": "string" },
"description": "Indexed columns"
},
"unique": {
"type": "boolean",
"description": "Whether index is unique"
},
"type": {
"type": "string",
"enum": ["btree", "hash", "gin", "gist", "brin", "fulltext", "spatial"],
"description": "Index type"
},
"sizeBytes": {
"type": "integer",
"minimum": 0,
"description": "Index size in bytes"
},
"usage": {
"type": "string",
"enum": ["high", "medium", "low", "unused"],
"description": "Index usage level"
}
}
},
"constraintIssue": {
"type": "object",
"required": ["type", "table", "issue"],
"properties": {
"type": {
"type": "string",
"enum": ["primary_key", "foreign_key", "unique", "check", "not_null", "default"],
"description": "Constraint type"
},
"table": {
"type": "string",
"description": "Table name"
},
"constraintName": {
"type": "string",
"description": "Constraint name"
},
"issue": {
"type": "string",
"description": "Issue description"
},
"affectedRows": {
"type": "integer",
"minimum": 0,
"description": "Rows violating constraint"
}
}
},
"indexIssue": {
"type": "object",
"required": ["table", "issue"],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"indexName": {
"type": "string",
"description": "Index name"
},
"issue": {
"type": "string",
"description": "Issue description"
},
"recommendation": {
"type": "string",
"description": "Recommended action"
},
"impactedQueries": {
"type": "integer",
"minimum": 0,
"description": "Number of queries impacted"
}
}
},
"dataIntegrity": {
"type": "object",
"description": "Data integrity test results",
"properties": {
"uniqueConstraintTests": {
"type": "object",
"properties": {
"passed": { "type": "integer" },
"failed": { "type": "integer" },
"violations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"table": { "type": "string" },
"constraint": { "type": "string" },
"duplicateCount": { "type": "integer" }
}
}
}
},
"description": "Unique constraint test results"
},
"foreignKeyTests": {
"type": "object",
"properties": {
"passed": { "type": "integer" },
"failed": { "type": "integer" },
"orphanedRecords": {
"type": "array",
"items": {
"type": "object",
"properties": {
"table": { "type": "string" },
"foreignKey": { "type": "string" },
"count": { "type": "integer" }
}
}
}
},
"description": "Foreign key constraint test results"
},
"checkConstraintTests": {
"type": "object",
"properties": {
"passed": { "type": "integer" },
"failed": { "type": "integer" },
"violations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"table": { "type": "string" },
"constraint": { "type": "string" },
"violationCount": { "type": "integer" }
}
}
}
},
"description": "Check constraint test results"
},
"nullConstraintTests": {
"type": "object",
"properties": {
"passed": { "type": "integer" },
"failed": { "type": "integer" },
"unexpectedNulls": {
"type": "array",
"items": {
"type": "object",
"properties": {
"table": { "type": "string" },
"column": { "type": "string" },
"nullCount": { "type": "integer" }
}
}
}
},
"description": "NOT NULL constraint test results"
}
}
},
"migrationTests": {
"type": "object",
"description": "Migration test results",
"properties": {
"migrationsFound": {
"type": "integer",
"minimum": 0,
"description": "Number of migrations found"
},
"migrationsTested": {
"type": "integer",
"minimum": 0,
"description": "Number of migrations tested"
},
"migrations": {
"type": "array",
"items": {
"$ref": "#/$defs/migrationResult"
},
"description": "Individual migration test results"
},
"pendingMigrations": {
"type": "array",
"items": { "type": "string" },
"description": "Migrations not yet applied"
},
"failedMigrations": {
"type": "array",
"items": { "type": "string" },
"description": "Migrations that failed to apply"
}
}
},
"migrationResult": {
"type": "object",
"required": ["name", "status"],
"properties": {
"name": {
"type": "string",
"description": "Migration name/identifier"
},
"version": {
"type": "string",
"description": "Migration version"
},
"status": {
"type": "string",
"enum": ["passed", "failed", "skipped", "pending"],
"description": "Migration test status"
},
"upTest": {
"type": "object",
"properties": {
"passed": { "type": "boolean" },
"durationMs": { "type": "integer" },
"error": { "type": "string" }
},
"description": "Forward migration test"
},
"downTest": {
"type": "object",
"properties": {
"passed": { "type": "boolean" },
"durationMs": { "type": "integer" },
"error": { "type": "string" }
},
"description": "Rollback migration test"
},
"dataPreservation": {
"type": "object",
"properties": {
"tested": { "type": "boolean" },
"passed": { "type": "boolean" },
"dataLossDetected": { "type": "boolean" },
"affectedRows": { "type": "integer" }
},
"description": "Data preservation test"
},
"idempotent": {
"type": "boolean",
"description": "Whether migration is idempotent"
}
}
},
"transactionTests": {
"type": "object",
"description": "Transaction/ACID test results",
"properties": {
"acidCompliance": {
"type": "object",
"properties": {
"atomicity": {
"$ref": "#/$defs/acidTest",
"description": "Atomicity test (all or nothing)"
},
"consistency": {
"$ref": "#/$defs/acidTest",
"description": "Consistency test (constraints valid)"
},
"isolation": {
"$ref": "#/$defs/acidTest",
"description": "Isolation test (concurrent access)"
},
"durability": {
"$ref": "#/$defs/acidTest",
"description": "Durability test (data persists)"
}
},
"description": "ACID property test results"
},
"isolationLevel": {
"type": "string",
"enum": ["READ_UNCOMMITTED", "READ_COMMITTED", "REPEATABLE_READ", "SERIALIZABLE"],
"description": "Current transaction isolation level"
},
"deadlockTests": {
"type": "object",
"properties": {
"tested": { "type": "boolean" },
"deadlocksDetected": { "type": "integer" },
"avgResolutionMs": { "type": "number" }
},
"description": "Deadlock detection tests"
},
"concurrencyTests": {
"type": "object",
"properties": {
"tested": { "type": "boolean" },
"maxConcurrent": { "type": "integer" },
"raceConditionsDetected": { "type": "integer" }
},
"description": "Concurrent access tests"
}
}
},
"acidTest": {
"type": "object",
"required": ["tested", "passed"],
"properties": {
"tested": {
"type": "boolean",
"description": "Whether this property was tested"
},
"passed": {
"type": "boolean",
"description": "Whether test passed"
},
"testCount": {
"type": "integer",
"minimum": 0,
"description": "Number of tests run"
},
"failureCount": {
"type": "integer",
"minimum": 0,
"description": "Number of failures"
},
"details": {
"type": "string",
"description": "Test details"
}
}
},
"performanceTests": {
"type": "object",
"description": "Query performance test results",
"properties": {
"queriesAnalyzed": {
"type": "integer",
"minimum": 0,
"description": "Number of queries analyzed"
},
"slowQueries": {
"type": "array",
"items": {
"$ref": "#/$defs/queryAnalysis"
},
"description": "Slow queries identified"
},
"missingIndexes": {
"type": "array",
"items": {
"$ref": "#/$defs/missingIndex"
},
"description": "Missing indexes identified"
},
"nPlusOneIssues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": { "type": "string" },
"queryPattern": { "type": "string" },
"queryCount": { "type": "integer" },
"recommendation": { "type": "string" }
}
},
"description": "N+1 query issues"
},
"connectionPoolMetrics": {
"type": "object",
"properties": {
"avgWaitMs": { "type": "number" },
"maxWaitMs": { "type": "number" },
"timeouts": { "type": "integer" },
"leaks": { "type": "integer" }
},
"description": "Connection pool performance"
},
"benchmarks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"avgMs": { "type": "number" },
"p50Ms": { "type": "number" },
"p95Ms": { "type": "number" },
"p99Ms": { "type": "number" },
"maxMs": { "type": "number" }
}
},
"description": "Performance benchmarks"
}
}
},
"queryAnalysis": {
"type": "object",
"required": ["query", "avgDurationMs"],
"properties": {
"query": {
"type": "string",
"description": "SQL query (anonymized)"
},
"avgDurationMs": {
"type": "number",
"minimum": 0,
"description": "Average execution time"
},
"maxDurationMs": {
"type": "number",
"minimum": 0,
"description": "Maximum execution time"
},
"executionCount": {
"type": "integer",
"minimum": 0,
"description": "Number of executions"
},
"rowsExamined": {
"type": "integer",
"minimum": 0,
"description": "Average rows examined"
},
"rowsReturned": {
"type": "integer",
"minimum": 0,
"description": "Average rows returned"
},
"usesIndex": {
"type": "boolean",
"description": "Whether query uses indexes"
},
"executionPlan": {
"type": "string",
"description": "Query execution plan"
},
"optimization": {
"type": "string",
"description": "Suggested optimization"
}
}
},
"missingIndex": {
"type": "object",
"required": ["table", "columns"],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"columns": {
"type": "array",
"items": { "type": "string" },
"description": "Columns that should be indexed"
},
"impact": {
"type": "string",
"enum": ["critical", "high", "medium", "low"],
"description": "Impact of missing index"
},
"affectedQueries": {
"type": "integer",
"minimum": 0,
"description": "Number of queries that would benefit"
},
"suggestedIndex": {
"type": "string",
"description": "SQL to create suggested index"
}
}
},
"databaseLocation": {
"type": "object",
"description": "Location in database",
"properties": {
"schema": {
"type": "string",
"description": "Database schema"
},
"table": {
"type": "string",
"description": "Table name"
},
"column": {
"type": "string",
"description": "Column name"
},
"constraint": {
"type": "string",
"description": "Constraint name"
},
"index": {
"type": "string",
"description": "Index name"
},
"migration": {
"type": "string",
"description": "Migration name"
},
"file": {
"type": "string",
"description": "Source file (for migration files)"
},
"line": {
"type": "integer",
"minimum": 1,
"description": "Line number in source file"
}
}
},
"databaseMetrics": {
"type": "object",
"properties": {
"totalFindings": {
"type": "integer",
"minimum": 0,
"description": "Total issues found"
},
"criticalCount": {
"type": "integer",
"minimum": 0,
"description": "Critical severity findings"
},
"highCount": {
"type": "integer",
"minimum": 0,
"description": "High severity findings"
},
"mediumCount": {
"type": "integer",
"minimum": 0,
"description": "Medium severity findings"
},
"lowCount": {
"type": "integer",
"minimum": 0,
"description": "Low severity findings"
},
"infoCount": {
"type": "integer",
"minimum": 0,
"description": "Informational findings"
},
"tablesAnalyzed": {
"type": "integer",
"minimum": 0,
"description": "Number of tables analyzed"
},
"constraintsValidated": {
"type": "integer",
"minimum": 0,
"description": "Number of constraints validated"
},
"indexesAnalyzed": {
"type": "integer",
"minimum": 0,
"description": "Number of indexes analyzed"
},
"migrationsAnalyzed": {
"type": "integer",
"minimum": 0,
"description": "Number of migrations analyzed"
},
"queriesAnalyzed": {
"type": "integer",
"minimum": 0,
"description": "Number of queries analyzed"
},
"testDurationMs": {
"type": "integer",
"minimum": 0,
"description": "Total test duration in milliseconds"
},
"coverage": {
"type": "object",
"properties": {
"schema": { "type": "boolean" },
"integrity": { "type": "boolean" },
"migration": { "type": "boolean" },
"transaction": { "type": "boolean" },
"performance": { "type": "boolean" }
},
"description": "Test coverage indicators"
}
}
},
"artifact": {
"type": "object",
"required": ["type", "path"],
"properties": {
"type": {
"type": "string",
"enum": ["report", "schema-dump", "migration-script", "data", "log", "query-plan", "benchmark"],
"description": "Artifact type"
},
"path": {
"type": "string",
"maxLength": 500,
"description": "Path to artifact"
},
"format": {
"type": "string",
"enum": ["json", "sql", "html", "md", "txt", "csv", "xml", "yaml"],
"description": "Artifact format"
},
"description": {
"type": "string",
"maxLength": 500,
"description": "Artifact description"
},
"sizeBytes": {
"type": "integer",
"minimum": 0,
"description": "File size in bytes"
},
"checksum": {
"type": "string",
"pattern": "^sha256:[a-f0-9]{64}$",
"description": "SHA-256 checksum"
}
}
},
"timelineEvent": {
"type": "object",
"required": ["timestamp", "event"],
"properties": {
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Event timestamp"
},
"event": {
"type": "string",
"maxLength": 200,
"description": "Event description"
},
"type": {
"type": "string",
"enum": ["start", "checkpoint", "warning", "error", "complete"],
"description": "Event type"
},
"durationMs": {
"type": "integer",
"minimum": 0,
"description": "Duration since previous event"
},
"phase": {
"type": "string",
"enum": ["initialization", "schema", "integrity", "migration", "transaction", "performance", "reporting"],
"description": "Test phase"
}
}
},
"metadata": {
"type": "object",
"properties": {
"executionTimeMs": {
"type": "integer",
"minimum": 0,
"maximum": 3600000,
"description": "Execution time in milliseconds"
},
"toolsUsed": {
"type": "array",
"items": {
"type": "string",
"enum": ["psql", "mysql", "mongo", "sqlite3", "knex", "prisma", "typeorm", "sequelize", "drizzle", "node", "pg-query-analyzer"]
},
"uniqueItems": true,
"description": "Database tools used"
},
"agentId": {
"type": "string",
"pattern": "^qe-[a-z][a-z0-9-]*$",
"description": "Agent ID"
},
"modelUsed": {
"type": "string",
"description": "LLM model used for analysis"
},
"inputHash": {
"type": "string",
"pattern": "^[a-f0-9]{64}$",
"description": "SHA-256 hash of input"
},
"targetPath": {
"type": "string",
"description": "Target path"
},
"environment": {
"type": "string",
"enum": ["development", "staging", "production", "ci"],
"description": "Execution environment"
},
"retryCount": {
"type": "integer",
"minimum": 0,
"maximum": 10,
"description": "Number of retries"
}
}
},
"validationResult": {
"type": "object",
"properties": {
"schemaValid": {
"type": "boolean",
"description": "Passes JSON schema validation"
},
"contentValid": {
"type": "boolean",
"description": "Passes content validation"
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Confidence score"
},
"warnings": {
"type": "array",
"items": {
"type": "string",
"maxLength": 500
},
"maxItems": 20,
"description": "Validation warnings"
},
"errors": {
"type": "array",
"items": {
"type": "string",
"maxLength": 500
},
"maxItems": 20,
"description": "Validation errors"
},
"validatorVersion": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$",
"description": "Validator version"
}
}
},
"learningData": {
"type": "object",
"properties": {
"patternsDetected": {
"type": "array",
"items": {
"type": "string",
"maxLength": 200
},
"maxItems": 20,
"description": "Database patterns detected (e.g., n-plus-one-query, missing-index)"
},
"reward": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Reward signal for learning (0.0-1.0)"
},
"feedbackLoop": {
"type": "object",
"properties": {
"previousRunId": {
"type": "string",
"format": "uuid",
"description": "Previous run ID for comparison"
},
"improvement": {
"type": "number",
"minimum": -1,
"maximum": 1,
"description": "Improvement over previous run"
}
}
},
"newDatabasePatterns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"pattern": { "type": "string" },
"category": { "type": "string" },
"confidence": { "type": "number" }
}
},
"description": "New database patterns learned"
}
}
}
}
}
{
"skillName": "database-testing",
"skillVersion": "1.0.0",
"requiredTools": [
"jq"
],
"optionalTools": [
"psql",
"mysql",
"mongo",
"sqlite3",
"node",
"ajv",
"jsonschema",
"python3"
],
"schemaPath": "schemas/output.json",
"requiredFields": [
"skillName",
"status",
"output",
"output.summary",
"output.findings",
"output.testTypes",
"output.databaseInfo"
],
"requiredNonEmptyFields": [
"output.summary"
],
"mustContainTerms": [
"database",
"schema",
"table"
],
"mustNotContainTerms": [
"TODO",
"placeholder",
"FIXME"
],
"enumValidations": {
".status": [
"success",
"partial",
"failed",
"skipped"
]
}
}