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.
import numpy as np
from dashboard_core.vector_healing import run_vector_healing
rng = np.random.default_rng(0)
vectors = rng.normal(0, 1, size=(30, 3))
vectors[10, 1] += 8.0 # a noise spike -- healed by the per-step Phi-Trigger
vectors[15, 0] = np.nan # genuine NaN corruption -- this is what fallback_triggered reports
result = run_vector_healing(vectors)
print(result.fallback_triggered) # True -- because of the NaN, NOT the spike (see note below)
print(result.healed_vectors[10]) # [0.115, -0.338, -0.044] -- spike replaced by the local median
print(vectors[10].tolist()) # [-1.010, 7.791, -0.159] -- the raw, unhealed value for comparison
fallback_triggered is narrower than it sounds: it's True only when genuine NaN/Inf
corruption was present and corrected, not whenever the Phi-Trigger replaces an outlier
spike with the local median — a spike-only run above (no NaN/Inf) heals vectors[10]
exactly the same way but reports fallback_triggered=False.
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.
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
Examples:
>>> import numpy as np
>>> from dashboard_core.vector_healing import run_vector_healing
>>> rng = np.random.default_rng(0)
>>> vectors = rng.normal(0, 1, size=(30, 3))
>>> vectors[10, 1] += 8.0 # a noise spike -- the Phi-Trigger heals this
>>> vectors[15, 0] = np.nan # genuine NaN corruption -- this is what fallback_triggered reports
>>> result = run_vector_healing(vectors)
>>> result.fallback_triggered # True only because of the NaN, not the spike
True
>>> abs(result.healed_vectors[10][1]) < 1.0 # spike replaced by the local median regardless
True
Source code in tools/dashboard/core/vector_healing.py
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.