  This paper presents an optimization based framework to automate system repair
against omega-regular properties. In the proposed formalization of optimal
repair, the systems are represented as Kripke structures, the properties as
$\omega$-regular languages, and the repair space as repair machines -- weighted
omega-regular transducers equipped with B\"uchi conditions -- that rewrite
strings and associate a cost sequence to these rewritings. To translate the
resulting cost-sequences to easily interpretable payoffs, we consider several
aggregator functions to map cost sequences to numbers -- including limit
superior, supremum, discounted-sum, and average-sum -- to define quantitative
cost semantics. The problem of optimal repair, then, is to determine whether
traces from a given system can be rewritten to satisfy an $\omega$-regular
property when the allowed cost is bounded by a given threshold. We also
consider the dual challenge of impair verification that assumes that the
rewritings are resolved adversarially under some given cost restriction, and
asks to decide if all traces of the system satisfy the specification
irrespective of the rewritings. With a negative result to the impair
verification problem, we study the problem of designing a minimal mask of the
Kripke structure such that the resulting traces satisfy the specifications
despite the threshold-bounded impairment. We dub this problem as the mask
synthesis problem. This paper presents automata-theoretic solutions to repair
synthesis, impair verification, and mask synthesis problem for limit superior,
supremum, discounted-sum, and average-sum cost semantics.
