Skip to content

Self Debug

self_debug — mvp.self_debug

Cluster: Code Intelligence | Type: component | MCP Tools: 26

Overview

Self-debugging and introspection block that audits, benchmarks, evaluates, and reports on G6 component health. Provides four operations — audit (structure checks), benchmark (timing over configurable iterations), evaluate (correctness probes), and report (summary of all metrics) — with optional component-level filtering so a pipeline can self-inspect any subset of its stack.

When to use:

  • Continuously monitoring G6 component correctness and latency within a running pipeline
  • Generating a health report before a deployment gate to confirm all critical components pass self-checks
  • Benchmarking a specific component in isolation to detect performance regressions

Example:

from mvp.self_debug import SelfDebugBlock, SelfDebugInput

block = SelfDebugBlock(name="self_debug")
result = block.infer(SelfDebugInput(operation="report", component_filter="solver"))
# result.ok → True; result.value → SelfDebugOutput with passed, summary, metrics

Works well with: system_doctor, auto_engineer, solver

Public API

SelfDebugInput(BaseModel)

Input for the Tier 1 SelfDebugBlock.

Field Type Default
operation Literal['audit', 'benchmark', 'evaluate', 'report', 'info', 'list_patterns'] 'info'
component_filter str ''
iterations int 100

SelfDebugOutput(BaseModel)

Output from the Tier 1 SelfDebugBlock.

Field Type Default
operation str required
passed bool True
summary str ''
metrics dict[str, float] Field(default_factory=dict)
details list[dict[str, Any]] Field(default_factory=list)
count int 0
degraded bool False
degradation_reason str \| None None
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] \| None None
evidence list[dict[str, Any]] Field(default_factory=list)
request_id str ''
task_id str ''
run_id str ''

SelfDebugBlock(AIBlock[SelfDebugInput, SelfDebugOutput, None])

Tier 1 self-debug block. Delegates to SelfDebugMCPBlock.

Field Type Default
name str 'self_debug'
db_path str field(default_factory=lambda: _DEFAULT_DB)
resource_bounds ResourceBounds \| None None
usage ResourceUsage field(default_factory=ResourceUsage)

Methods:

infer(data: SelfDebugInput) -> Result[SelfDebugOutput]

MCPSelfDebugInput(BaseModel)

Input for the self-debug MCP block.

Field Type Default
op Literal['audit_wiring', 'audit_schemas', 'audit_imports', 'audit_stores', 'audit_registry', 'bench_registry', 'bench_invocation', 'bench_store', 'bench_routing', 'bench_pipeline', 'bench_memory', 'eval_routing_accuracy', 'eval_navigator_e2e', 'eval_grounding_quality', 'eval_coverage', 'report_summary', 'report_regressions', 'report_component', 'report_cluster', 'get_history', 'discover_components', 'inspect_component', 'configure_thresholds', 'run_suite', 'info', 'list_patterns'] required
component str ''
cluster str ''
iterations int 100
run_id str ''
metric str ''
threshold_value float 0.0
limit int 50
suite str ''
block_names list[str] Field(default_factory=list)
query str ''
auto_heal bool False

MCPSelfDebugOutput(BaseModel)

Output from the self-debug MCP block.

Field Type Default
op str required
result str ''
passed bool True
metrics dict[str, float] Field(default_factory=dict)
details list[dict[str, Any]] Field(default_factory=list)
message str ''
count int 0
metadata dict[str, Any] Field(default_factory=dict)
degraded bool False
degradation_reason str \| None None
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] \| None None
evidence list[dict[str, Any]] Field(default_factory=list)
request_id str ''
task_id str ''
run_id str ''

SelfDebugMCPBlock(AIBlock[MCPSelfDebugInput, MCPSelfDebugOutput, dict])

25-op self-debug MCP block with SQLite persistence.

Field Type Default
name str 'self_debug_mcp'
state dict \| None None
db_path str field(default_factory=lambda: _DEFAULT_DB)
resource_bounds ResourceBounds \| None None
usage ResourceUsage field(default_factory=ResourceUsage)

Methods:

set_registry(registry: object) -> None

Inject a registry for cross-component integration (e.g. auto_heal).

infer(data: MCPSelfDebugInput) -> Result[MCPSelfDebugOutput]

SelfDebugStore

Sync SQLite store with 3 tables: bench_results, thresholds, runs.

Constructor:

Parameter Type Default
db_path str ':memory:'

Methods:

create_run(suite: str, component_filter: str = '', git_sha: str = '') -> str

finish_run(run_id: str, total_pass: int, total_fail: int, summary: dict[str, Any] | None = None) -> None

get_run(run_id: str) -> dict[str, Any] | None

list_runs(suite: str = '', limit: int = 20) -> list[dict[str, Any]]

add_result(run_id: str, suite: str, op: str, metric: str, value: float, component: str = '', threshold: float | None = None, passed: bool = True) -> str

get_results(run_id: str = '', suite: str = '', op: str = '', component: str = '', metric: str = '', limit: int = 500) -> list[dict[str, Any]]

set_threshold(metric: str, value: float) -> None

get_threshold(metric: str) -> float | None

list_thresholds() -> dict[str, float]

add_healing_episode(episode_id: str, component: str, error_type: str, error_message: str = '', tier_used: int = 0, outcome: str = '', reward: float = 0.0, duration_seconds: float = 0.0, fix_applied: str = '', verified: bool = False) -> str

get_healing_episodes(component: str = '', outcome: str = '', limit: int = 100) -> list[dict[str, Any]]

count_all() -> dict[str, int]

MCP Tools

Operation Source
audit_wiring self_debug_mcp
audit_schemas self_debug_mcp
audit_imports self_debug_mcp
audit_stores self_debug_mcp
audit_registry self_debug_mcp
bench_registry self_debug_mcp
bench_invocation self_debug_mcp
bench_store self_debug_mcp
bench_routing self_debug_mcp
bench_pipeline self_debug_mcp
bench_memory self_debug_mcp
eval_routing_accuracy self_debug_mcp
eval_navigator_e2e self_debug_mcp
eval_grounding_quality self_debug_mcp
eval_coverage self_debug_mcp
report_summary self_debug_mcp
report_regressions self_debug_mcp
report_component self_debug_mcp
report_cluster self_debug_mcp
get_history self_debug_mcp
discover_components self_debug_mcp
inspect_component self_debug_mcp
configure_thresholds self_debug_mcp
run_suite self_debug_mcp
info self_debug_mcp
list_patterns self_debug_mcp