/** * Per-position-instance baseline for the "Stop raised" (DSL_STOP_RAISE) gate. * * A DSL exchange-SL placement emits `SL_UPDATED` on the initial placement, on * every genuine trailing raise, AND on non-raise re-derivations (tier-index * reset, decreasing `lock_hw_pct`, backend-handoff re-anchoring). Only a GENUINE * raise — the stop moving strictly more favorable (higher for LONG, lower for * SHORT) than the most-favorable stop already seen for THIS position instance — * should notify. This ratchet answers exactly that. * * Keyed by `correlationId` (minted fresh per DSL-state rebuild in * `initial-state.ts` → increase/decrease/flip/resize auto-resets the baseline; * no explicit clear needed). Falls back to the cross-flow position key when a * payload lacks a correlationId, so a missing id never collapses distinct * positions onto one `undefined` bucket. * * The baseline is the RATCHET of every floor seen for the instance (`max` LONG / * `min` SHORT): a non-favorable `SL_UPDATED` must NOT lower it, so a recovery * back to a previously-announced level after a retreat does not re-fire. * `evaluate()` advances the baseline on EVERY call (including * correlator-suppressed profit-locks) — the raise verdict it returns is computed * against the PRIOR baseline, before the advance. */ /** * Idle lifetime (ms, wall-clock) before an untouched baseline is treated as * abandoned. Refreshed on EVERY `evaluate()` for the key, so an actively-trading * position (ticks far more often than this) never expires — only a * closed/replaced instance, whose fresh rebuild already mints a new * correlationId, ages out. Generous by design: it only bounds memory, never * gates a live raise. */ export declare const RATCHET_IDLE_TTL_MS: number; /** Hard size backstop: past this, the least-recently-touched entry is evicted. */ export declare const RATCHET_MAX_ENTRIES = 5000; export interface StopRaiseRatchetOptions { /** Injectable clock for TTL/eviction in tests. Defaults to `Date.now`. */ now?: () => number; ttlMs?: number; maxEntries?: number; } /** * Maintains, per position instance, the most-favorable exchange-SL floor seen * and reports whether a new floor is a genuine raise beyond it. */ export declare class StopRaiseRatchet { private readonly entries; private readonly now; private readonly ttlMs; private readonly maxEntries; constructor(opts?: StopRaiseRatchetOptions); /** * Ratchet the instance baseline toward favorable and report whether this floor * is a GENUINE raise (strictly more favorable than the PRIOR baseline). * * Always advances the baseline (unconditionally, before any caller-side * suppression). Returns: * - `false` for the first floor of a new/expired instance (establishing the * stop — not a raise) and for any non-favorable floor (a retreat leaves the * baseline untouched). * - `true` only when `newSLPrice` beats the prior baseline in the favorable * direction. * * Defensive: a non-finite price or an unknown direction cannot be judged → * returns `false` and leaves the baseline untouched (WARN once per call). */ evaluate(key: string, newSLPrice: number, direction: "LONG" | "SHORT" | undefined): boolean; /** Test/observability helper. */ size(): number; /** Test helper: current baseline for a key (undefined if none). */ peek(key: string): number | undefined; /** Insert/update with LRU recency (delete-then-set moves the key to the tail). */ private write; /** Evict the least-recently-touched entry (map head under LRU ordering). */ private evictOldest; } //# sourceMappingURL=stop-raise-ratchet.d.ts.map