Skip to content

Adapt Bias

adapt_bias — Self-evolving inductive bias system with MLflow integration.

Cluster: Uncategorised | Type: component | MCP Tools: 33

Overview

Behavioral parameter-bias tuning orchestrator for bounded inductive-bias experiments. Observes system performance, proposes targeted parameter mutations for component-declared evolvable_params, verifies them against grounding and safety layers, and persists approved parameter versions with rollback support. It does not perform general fairness-bias detection unless a downstream component exposes those parameters and benchmarks, and it does not modify implementation files.

When to use:

  • Tuning bounded component parameters based on workflow performance
  • Running controlled evolution experiments on specific components
  • Auditing the current bias landscape across all registered components

When not to use:

  • As the first workflow for a new non-technical user
  • Without a human reviewer approving the mutation token
  • For regulated-domain outputs without a separate human review and compliance process

Example:

from mvp.adapt_bias import BiasEvolutionBlock, BiasInput

block = BiasEvolutionBlock(name="bias_evo")
result = block.infer(BiasInput(op="snapshot"))
# result.value.snapshot → dict of all component biases

Works well with: align_csf, formal_methods, adapt_memory, grounding

Operations

Operation Tier Description
snapshot Basic Collect current bias landscape from all registered components
observe Basic Classify current situation via context_engine + always-on memory
understand Basic Structural analysis via self_model + deep_understanding
evaluate Basic Multiobjective fitness scoring (speed, cost, quality, Pareto)
evolve Premium Generate a qualified-draft parameter candidate, preferring benchmark evidence when available
apply Premium Persist an approved parameter version with safety verification and rollback metadata
rollback Premium Revert a component to a previous bias version
ground_check Basic Check a candidate bias against theoretical foundations
self_heal Basic Automated self-debugging after bias mutations

Configuration

See BiasEvolutionConfig for all configuration fields. Key environment variables:

BIAS_EVOLUTION_ENABLED=true          # Master feature flag
BIAS_EVOLUTION_CONFIRM_TOKEN=...     # Required for evolve/apply/rollback
BIAS_EVOLUTION_TIER=premium          # Or trialing for time-limited access
BIAS_DB_PATH=~/.bias_mcp/bias.db     # SQLite fallback path
BIAS_EVOLUTION_AUTO_EVOLVE=false     # Auto-run on workflow completion
BIAS_EVOLUTION_MAX_ITERATIONS=5      # Max proposals per cycle
BIAS_EVOLUTION_SAFETY_LAYERS=4       # Required safety layers

BIAS_EVOLUTION_CONFIRM_TOKEN is deliberately separate from API keys and license tier. Keep it in deployment configuration, not in prompts or reusable workflow definitions. Public MCP/REST callers must provide the matching confirm_token for mutating operations.

If MLflow is installed, get_store() uses the MLflow-backed store. Otherwise it falls back to SQLite at BIAS_DB_PATH or ~/.bias_mcp/bias.db, which is suitable for single-user local MCP pilots.

Public API

ABResult

Result of an A/B comparison between two bias configurations.

Field Type Default
baseline_pass_rate float required
candidate_pass_rate float required
baseline_avg_ms float required
candidate_avg_ms float required
pass_rate_delta float required
latency_delta_ms float required
improvement bool required

BiasEvolutionBlock(AIBlock['BiasInput', 'BiasOutput', dict])

Orchestrator for self-evolving inductive biases.

Field Type Default
name str 'bias_evolution'
resource_bounds ResourceBounds \| None None
usage ResourceUsage field(default_factory=ResourceUsage)
state dict \| None field(default_factory=dict)

Methods:

infer(data: BiasInput) -> Result[BiasOutput]

Dispatch to the appropriate operation handler.

bias() -> dict[str, Any]

BiasInput(BaseModel)

Input for BiasEvolutionBlock operations.

Field Type Default
op Literal['snapshot', 'observe', 'understand', 'evaluate', 'evolve', 'evolve_orchestrated', 'apply', 'rollback', 'ground_check', 'self_heal', 'discover_capabilities', 'backend_native_op', 'generate_benchmarks_from_grounding', 'wiring_audit'] required
target_component str ''
workflow_trace dict[str, Any] \| None None
bias_candidate dict[str, Any] \| None None
evolution_config dict[str, Any] \| None None
rollback_version int -1
weights dict[str, float] \| None None
objective Literal['pass_rate', 'latency', 'balanced'] 'balanced'
benchmark_cases list[dict[str, Any]] \| None None
confirm_token str ''
subscription_tier str ''
backend str ''
native_operation str ''
payload dict[str, Any] \| None None
safety_context dict[str, Any] \| None None
dry_run bool True

BiasOutput(BaseModel)

Output from BiasEvolutionBlock operations.

Field Type Default
op str ''
ok bool True
message str ''
snapshot dict[str, Any] \| None None
evaluation dict[str, Any] \| None None
proposal dict[str, Any] \| None None
frontier list[dict[str, Any]] \| None None
grounding_report dict[str, Any] \| None None
healing_report dict[str, Any] \| None None
safety_layer_report SafetyLayerReport \| None None
situation str ''
applied bool False
version int 0
warnings list[str] Field(default_factory=list)
degraded bool False
degradation_reason str \| None None
degradation dict[str, Any] \| None None
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] \| None None
evidence dict[str, Any] Field(default_factory=dict)
request_id str ''
task_id str ''
run_id str ''

BiasStoreABC(ABC)

Contract for bias-parameter storage backends.

Methods:

is_available() -> bool

Return True if this backend's dependencies are installed.

record_version(component: str, version: int, bias: dict[str, Any], metadata: dict[str, Any] | None = None) -> str

Persist a new bias version and return its record id.

get_versions(component: str, limit: int = 50) -> list[dict[str, Any]]

Return the most recent limit versions for component.

get_version(component: str, version: int) -> dict[str, Any] | None

Return a single version record, or None if not found.

record_evolution(component: str, op: str, input_data: dict[str, Any], output_data: dict[str, Any], metrics: dict[str, float] | None = None, artifacts: dict[str, Any] | None = None) -> str

Log an evolution operation and return its record id.

get_evolution_log(component: str = '', op: str = '', limit: int = 50) -> list[dict[str, Any]]

Query evolution history, optionally filtered by component/op.

record_grounding(component: str, candidate: dict[str, Any], report: dict[str, Any], passed: bool, artifacts: dict[str, Any] | None = None) -> str

Log a grounding check result and return its record id.

get_grounding_log(component: str = '', limit: int = 50) -> list[dict[str, Any]]

Query grounding history, optionally filtered by component.

promote(component: str, version: int, reason: str) -> dict[str, Any]

Promote a version to the next lifecycle stage.

get_stage_status(component: str) -> dict[str, Any]

Return the current lifecycle stage for component.

text_search(query: str, limit: int = 20) -> list[dict[str, Any]]

Full-text search across stored records.

count_all() -> dict[str, int]

Return counts of records by category.

clear_all() -> None

Delete all records (use with caution).

compare_runs(run_id_a: str, run_id_b: str) -> dict[str, Any]

Compare two runs and return a diff summary.

update_run_metrics(run_id: str, metrics: dict[str, float]) -> None

Update metrics on an existing run. Best-effort — may be a no-op.

AdaptBiasMCPBlock(AIBlock[MCPBiasInput, MCPBiasOutput, dict])

MCP-tier bias evolution block with SQLite persistence.

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

Methods:

infer(data: MCPBiasInput) -> Result[MCPBiasOutput]

MCPBiasInput(BaseModel)

Field Type Default
op Literal['snapshot', 'observe', 'understand', 'evaluate', 'evolve', 'apply', 'rollback', 'ground_check', 'discover_capabilities', 'backend_native_op', 'generate_benchmarks_from_grounding', 'wiring_audit', 'list_versions', 'get_version', 'compare_versions', 'query_memory', 'ingest_observation', 'check_principle', 'list_principles', 'grounding_report', 'self_heal', 'health_check', 'reset', 'export_state', 'import_state', 'clear_history', 'info', 'status', 'search', 'promote', 'stage_status', 'compare_runs', 'dashboard'] required
component str \| None None
subscription_tier str \| None None
workflow_trace dict[str, Any] \| None None
bias_candidate dict[str, Any] \| None None
evolution_config dict[str, Any] \| None None
confirm_token str ''
version int \| None None
query str \| None None
principle str \| None None
compare_from int \| None None
compare_to int \| None None
state_data dict[str, Any] \| None None
reason str \| None None
run_id_a str \| None None
run_id_b str \| None None
backend str \| None None
native_operation str \| None None
payload dict[str, Any] \| None None
safety_context dict[str, Any] \| None None
dry_run bool True

MCPBiasOutput(BaseModel)

Field Type Default
ok bool True
message str ''
data dict[str, Any] \| None None
warnings list[str] []
degraded bool False
degradation_reason str \| None None

SqliteBiasStore(BiasStoreABC)

SQLite-backed store for the adapt_bias MCP sub-package.

Constructor:

Parameter Type Default
db_path str ':memory:'

Methods:

is_available() -> bool

record_version(component: str, version: int, bias: dict[str, Any], metadata: dict[str, Any] | None = None) -> str

Record a new bias version. Returns the assigned id.

get_versions(component: str, limit: int = 50) -> list[dict[str, Any]]

List all versions for a component, newest first.

get_version(component: str, version: int) -> dict[str, Any] | None

Get a specific version. Returns None if not found.

record_evolution(component: str, op: str, input_data: dict[str, Any], output_data: dict[str, Any], metrics: dict[str, float] | None = None, artifacts: dict[str, Any] | None = None) -> str

Log an evolution operation. Returns the assigned id.

get_evolution_log(component: str = '', op: str = '', limit: int = 50) -> list[dict[str, Any]]

Query evolution log, optionally filtered by component and/or op.

update_run_metrics(run_id: str, metrics: dict[str, float]) -> None

Merge additional metrics into an existing evolution_log row.

record_grounding(component: str, candidate: dict[str, Any], report: dict[str, Any], passed: bool, artifacts: dict[str, Any] | None = None) -> str

Log a grounding check result. Returns the assigned id.

get_grounding_log(component: str = '', limit: int = 50) -> list[dict[str, Any]]

Query grounding log, optionally filtered by component.

clear_all() -> None

Clear all tables.

count_all() -> dict[str, int]

text_search(query: str, limit: int = 10) -> list[dict[str, Any]]

Search across evolution_log by component + op text.

promote(component: str, version: int, reason: str) -> dict[str, Any]

get_stage_status(component: str) -> dict[str, Any]

compare_runs(run_id_a: str, run_id_b: str) -> dict[str, Any]

Functions

ab_compare(component_name: str, baseline_bias: dict[str, Any], candidate_bias: dict[str, Any], benchmark_cases: list[dict[str, Any]]) -> ABResult

Run the same benchmark suite with baseline vs candidate bias.

get_store(db_path: str | None = None, tracking_uri: str | None = None) -> BiasStoreABC

Create the best available bias store backend.

MCP Tools

Operation Source
snapshot bias_mcp
observe bias_mcp
understand bias_mcp
evaluate bias_mcp
evolve bias_mcp
apply bias_mcp
rollback bias_mcp
ground_check bias_mcp
discover_capabilities bias_mcp
backend_native_op bias_mcp
generate_benchmarks_from_grounding bias_mcp
wiring_audit bias_mcp
list_versions bias_mcp
get_version bias_mcp
compare_versions bias_mcp
query_memory bias_mcp
ingest_observation bias_mcp
check_principle bias_mcp
list_principles bias_mcp
grounding_report bias_mcp
self_heal bias_mcp
health_check bias_mcp
reset bias_mcp
export_state bias_mcp
import_state bias_mcp
clear_history bias_mcp
info bias_mcp
status bias_mcp
search bias_mcp
promote bias_mcp
stage_status bias_mcp
compare_runs bias_mcp
dashboard bias_mcp

REST Endpoints (7)

Exposed at /api/v1/bias/*. See the Bias Evolution API Reference for request/response schemas.