- New tables: components, component_dependencies, component_files, verification_checks, change_impacts, impact_analysis_runs - 8 new MCP tools: component_register, component_list, component_add_dependency, component_add_file, component_add_check, impact_analysis, impact_learn, component_graph - Seed data: 17 components, 9 dependencies, 12 file patterns, 5 checks - Historical impacts from session 397 issues recorded Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
79 lines
3.0 KiB
SQL
79 lines
3.0 KiB
SQL
-- Impact Analysis Schema
|
|
-- Tracks system components, dependencies, and verification checks
|
|
|
|
-- Components registry
|
|
CREATE TABLE IF NOT EXISTS components (
|
|
id TEXT PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
type TEXT NOT NULL CHECK (type IN ('service', 'script', 'config', 'database', 'api', 'ui', 'library')),
|
|
path TEXT,
|
|
repo TEXT,
|
|
description TEXT,
|
|
health_check TEXT,
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Component dependencies (directed graph)
|
|
CREATE TABLE IF NOT EXISTS component_dependencies (
|
|
id SERIAL PRIMARY KEY,
|
|
component_id TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
depends_on TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
dependency_type TEXT NOT NULL CHECK (dependency_type IN ('hard', 'soft', 'config', 'data')),
|
|
description TEXT,
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
UNIQUE(component_id, depends_on)
|
|
);
|
|
|
|
-- File-to-component mapping (for git diff analysis)
|
|
CREATE TABLE IF NOT EXISTS component_files (
|
|
id SERIAL PRIMARY KEY,
|
|
component_id TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
file_pattern TEXT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
UNIQUE(component_id, file_pattern)
|
|
);
|
|
|
|
-- Verification checks per component
|
|
CREATE TABLE IF NOT EXISTS verification_checks (
|
|
id SERIAL PRIMARY KEY,
|
|
component_id TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
name TEXT NOT NULL,
|
|
check_type TEXT NOT NULL CHECK (check_type IN ('command', 'http', 'tcp', 'file')),
|
|
check_command TEXT NOT NULL,
|
|
expected_result TEXT,
|
|
timeout_seconds INTEGER DEFAULT 30,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Historical change impacts (learned from errors)
|
|
CREATE TABLE IF NOT EXISTS change_impacts (
|
|
id SERIAL PRIMARY KEY,
|
|
changed_component TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
affected_component TEXT NOT NULL REFERENCES components(id) ON DELETE CASCADE,
|
|
impact_description TEXT NOT NULL,
|
|
error_id TEXT,
|
|
task_id TEXT,
|
|
learned_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Impact analysis runs (audit log)
|
|
CREATE TABLE IF NOT EXISTS impact_analysis_runs (
|
|
id SERIAL PRIMARY KEY,
|
|
task_id TEXT,
|
|
triggered_by TEXT NOT NULL CHECK (triggered_by IN ('task_close', 'manual', 'git_push')),
|
|
components_analyzed INTEGER DEFAULT 0,
|
|
issues_found INTEGER DEFAULT 0,
|
|
verification_passed BOOLEAN,
|
|
details JSONB,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Indexes for performance
|
|
CREATE INDEX IF NOT EXISTS idx_component_deps_component ON component_dependencies(component_id);
|
|
CREATE INDEX IF NOT EXISTS idx_component_deps_depends ON component_dependencies(depends_on);
|
|
CREATE INDEX IF NOT EXISTS idx_component_files_component ON component_files(component_id);
|
|
CREATE INDEX IF NOT EXISTS idx_change_impacts_changed ON change_impacts(changed_component);
|
|
CREATE INDEX IF NOT EXISTS idx_change_impacts_affected ON change_impacts(affected_component);
|
|
CREATE INDEX IF NOT EXISTS idx_impact_runs_task ON impact_analysis_runs(task_id);
|