Skip to content

Dashboard Core — Vector Healing (Composer's healing panel)

Real predictive-healing pass over a noisy vector sequence (VQE/MD telemetry, quantum state trajectories, or any other (n_steps, dim) array) — a thin dashboard-facing wrapper around ia_utils.vector_healing.enhanced_dense_healing_hybrid, lazily imported so a missing/stripped ia_utils install fails with a clear error at call time rather than breaking dashboard_core import for everyone.

vector_healing

Real predictive-healing pass over a noisy vector sequence (VQE/MD telemetry, quantum state trajectories, or any other (n_steps, dim) array) -- a thin wrapper around ia_utils.vector_healing.enhanced_dense_healing_hybrid, which itself is built on dense_evolution.healing's Phi-Trigger primitives (calculate_phi_ab, calculate_vettore_dinamico, evaluate_phi_trigger).

This existed in the pre-rebuild dashboard_core (Streamlit dashboard's "AI healing shield" middleware, routing VQE/MD telemetry through it before any panel was built from it) but was left behind when dashboard_core was rebuilt around the Composer kernel -- see this package's init.py docstring ("will be reintegrated selectively once this base is solid"). Reintegrated here as its own module, mirroring mitigation.py's shape (a dataclass result + one thin run_* function), rather than resurrecting the old monolithic dashboard_core.py.

run_vector_healing

run_vector_healing(
    vectors: ndarray, radius_baseline: Optional[int] = None
) -> VectorHealingResult

Heal a noisy (n_steps, dim) vector sequence: per step, a Phi-Trigger (dense_evolution.healing) decides whether the change from a local baseline looks like genuine dynamics (kept as-is) or static noise (replaced by the local median) -- see ia_utils.vector_healing.enhanced_dense_healing_hybrid's own docstring for the full algorithm. NaN/Inf entries are sanitized first (column-mean imputation) regardless of the trigger's decision.

Parameters:

Name Type Description Default
vectors ndarray

array-like, shape (n_steps, dim), n_steps >= 0.

required
radius_baseline Optional[int]

fixed radius for the local baseline window; if None (default), computed adaptively as min(20, max(3, n_steps // 3)).

None

Returns:

Type Description
VectorHealingResult

VectorHealingResult

Source code in tools/dashboard_core/vector_healing.py
def run_vector_healing(vectors: np.ndarray, radius_baseline: Optional[int] = None) -> VectorHealingResult:
    """Heal a noisy (n_steps, dim) vector sequence: per step, a Phi-Trigger
    (dense_evolution.healing) decides whether the change from a local
    baseline looks like genuine dynamics (kept as-is) or static noise
    (replaced by the local median) -- see
    ia_utils.vector_healing.enhanced_dense_healing_hybrid's own docstring
    for the full algorithm. NaN/Inf entries are sanitized first
    (column-mean imputation) regardless of the trigger's decision.

    Args:
        vectors: array-like, shape (n_steps, dim), n_steps >= 0.
        radius_baseline: fixed radius for the local baseline window; if
            None (default), computed adaptively as
            min(20, max(3, n_steps // 3)).

    Returns:
        VectorHealingResult
    """
    if enhanced_dense_healing_hybrid is None:
        raise ImportError(
            "run_vector_healing requires ia_utils.vector_healing, which failed "
            f"to import ({_IMPORT_ERROR}). It ships with dense-evolution's own "
            "packages, so this usually means a stripped/vendored install is "
            "missing it, or one of its own dependencies (dense_evolution.healing "
            "needs JAX) isn't available."
        )

    arr = np.asarray(vectors, dtype=np.float64)
    if arr.ndim != 2:
        raise ValueError(f"vectors must be 2D (n_steps, dim), got shape {arr.shape}")

    healed, metadata = enhanced_dense_healing_hybrid(arr, radius_baseline=radius_baseline)

    return VectorHealingResult(
        healed_vectors=healed.tolist(),
        fallback_triggered=bool(metadata['fallback_triggered']),
        adaptive_radius_used=int(metadata['adaptive_radius_used']),
        reconstruction_error=float(metadata['reconstruction_error']),
    )

Not to be confused with ia_utils.vector_healing (same name, different module) — that one has the real median_healing/enhanced_dense_healing_hybrid implementation; this one is the dashboard's request/response wrapper around it.