"""Host-conditioned causal reference binding for real source-to-target handoff. No generated answer targets, gradients on hosts, or persisted host-private KV. """ import torch from torch.nn import functional as F from .observations import observation_text,temporal_notes class NativeBindingWriter: def __init__(self,state,bridge,source_host,window=4): self.state=state;self.bridge=bridge;self.host=bridge.host;self.source_host=source_host;self.window=window self.layer=max(0,(len(self.host.model.layers)*2)//3-1);self.forwards=0;self.tokens=0;self.trace=[] def canonical(self,o): text=observation_text(o);note=temporal_notes(o) if note:text+="; Time reference: "+note tok=self.state.core.codec.tokenizer return tok.decode(tok.encode(text,add_special_tokens=False),skip_special_tokens=True) def previous(self,obs,j): n=len(self.state.meta);result=[] for index in range(max(0,n+j-self.window),n+j): if index