We propose a programmable automatic protection switching (APS) protocol to repair an impaired lightpath traversing an optical link. Recovery agents repair impaired flows by searching through a space of policies before attempting a protection switch and after switching impaired traffic. A policy manager disseminates a changeable set of polices to each agent and ensures consistent interpretation end-to-end QoS. QoS policies are structured to be interpreted in the same way by developing a model ofend-to-end QoS over which logic formulae can be checked for satisfaction.Reconfiguring recovery agents supports faster service innovation by deploying new network services to the nodes interior to the network. Programmability is built into the optical layer termination functions on each lightpath. Attached to recovery