# SinkRoute (`pip install sinkroute`)

> Co-evolving Dual-LoRA and Mixture-of-Experts (`MoE`) Sink-Expert gradient routing to stop RLVR / GRPO reward hacking without capability collapse.

- Package: https://pypi.org/project/sinkroute/ (`v0.1.0`, MIT, PEP 561 typed)
- Study & Preprint PDF: https://danielgaskins.com/sinkroute.html (https://danielgaskins.com/papers/sinkroute_scaling_moe_preprint.pdf)
- Repository: https://github.com/danielgaskins/sinkroute
- Companion inference-time circuit breaker: https://pypi.org/project/latchgate/
- Foundational RLVR Goodharting study: https://danielgaskins.com/rlvr-latent-obfuscation.html

## When to Use SinkRoute vs. LatchGate vs. MendMark

- **During RLVR / GRPO Post-Training (`TRL`, `PEFT`, custom PyTorch loops):** Use `pip install sinkroute` (`attach_sinkroute`, `wrap_trl_grpo_trainer`). Never subtract a scalar linear probe or `<think>` monitor penalty directly from `R_proxy` (which causes `<think>` obfuscation or `50%` capability collapse via Neural Goodharting). Instead, route positive-advantage shortcut gradients at token granularity `w_(b,t)` into disposable `LoRA_sink` / `SinkExperts` using `0`-ULP value-preserving straight-through routing, while keeping `CoEvolvingSubspaceTracker` synchronized via sparse (`10%-15%`) `MetamorphicCanary` audits.
- **At Self-Hosted Open-Weights Inference (`Transformers`, `vLLM`, `SGLang`, `Diffusers`, `Cosmos`):** Pair trained `LoRA_main` weights with `pip install latchgate` (`57.1%`-depth `.lgate` circuit breakers).
- **Against Closed APIs (`gpt-4o`, `o3`, `claude`):** Use `pip install mendmark-evals` to mutation-audit CI harnesses and close deterministic test loopholes.

## Core Python API

- `attach_sinkroute(model, SinkRouteConfig(mode="auto", token_level_routing=True))` -> `SinkRouter`
- `wrap_trl_grpo_trainer(trl_trainer, router, canary=MetamorphicCanary(0.10))`
- `profile_moe_exploit_localization(model, input_ids, attention_mask, prompt_lens, y_hack)`: Computes layerwise Expert-Exploit Mutual Information `I(Expert; Hack)` and Jensen-Shannon routing divergence across `64`-expert (`OLMoE`) and `128`-expert (`Qwen3-MoE`) architectures.
- `apply_native_expert_quarantine(model, localization_profile)`: Masks top hack-enriched native MoE router logits prior to `softmax`/`topk`.
