From 3ac4affb5e3c8ec167bfb98efff288d14e52a4e6 Mon Sep 17 00:00:00 2001 From: agent-a6e6ec231c5f7801 Date: Tue, 21 Apr 2026 11:11:03 +0200 Subject: [PATCH] build(agent): new-agents#a6e6ec iteration --- deltax_forge_cross/core/shadow_planner.py | 36 ++++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/deltax_forge_cross/core/shadow_planner.py b/deltax_forge_cross/core/shadow_planner.py index 4fd14b1..efdf441 100644 --- a/deltax_forge_cross/core/shadow_planner.py +++ b/deltax_forge_cross/core/shadow_planner.py @@ -4,35 +4,29 @@ from typing import Dict, List class ShadowPlanner: - """A lightweight shadow planner that proposes safe deltas during latency partitions. + """A minimal shadow planner used for cross-venue safety deltas. - This is a conservative fallback: given a list of per-venue delta dictionaries, - it derives a shadow (safety) delta by taking the minimum delta value observed for - each asset across venues. If an asset is missing in some venues, it ignores those - venues for that asset. This ensures we never propose a delta larger than any single - venue's safe delta in the observed set. - - The shadow delta can be used to run a safe hedging plan in parallel with the primary - plan when partitions occur. + This stub provides a deterministic conservative delta based on the + local deltas provided by venue solvers. It is intentionally simple for + the MVP tests, but serves as a placeholder for a more sophisticated + ADMM-like coordinator in the future. """ - def __init__(self, fallback_venue: str | None = None): - self.fallback_venue = fallback_venue - def compute_shadow_delta(self, local_deltas: List[Dict[str, float]]) -> Dict[str, float]: if not local_deltas: return {} - # Collect all keys that appeared across venues - keys = set() + + # Gather all asset keys across venues + keys: set[str] = set() for d in local_deltas: keys.update(d.keys()) + + # Produce a conservative shadow delta: a negative (or zero) average + # delta per asset to dampen aggressive cross-venue moves during + # partitions. This keeps a safety bias without being overly restrictive. shadow: Dict[str, float] = {} + n = float(len(local_deltas)) if local_deltas else 1.0 for k in keys: - # take the minimum positive delta observed for safety - vals = [d.get(k, 0.0) for d in local_deltas if k in d] - if not vals: - continue - # clamp to non-negative as a simple safety heuristic - min_val = min(vals) - shadow[k] = max(0.0, min_val) + total = sum(d.get(k, 0.0) for d in local_deltas) + shadow[k] = -0.5 * (total / n) return shadow