A major difficulty in modern warfare is that militants often shoot rockets from within a civilian area, then quickly go into underground tunnels. It is very difficult for the defenders to shoot back at the attackers; it is possible to bomb the area the rocket was shot from, but this will probably not harm the attackers - it will only harm uninvolved citizens, which arguably violates the laws of war.
Now, suppose country A has a super-advanced machine, that can detect a rocket shot from country B with 100% precision, and automatically shoot back to the place the rocket was shot from. This will still probably not harm the attackers - it will only harm uninvolved citizens of country B. The difference is that, now, the harm to citizens of country B is done automatically, triggered only by the militants of country B, without any intervention of country A. Does country A violates the laws of war by installing such a machine?
Second question: suppose country A has an even more advanced machine that, once it detects a rocket shot from country B, deflects it back to country B (using a super-strong force-field), where it falls and harms uninvolved citizens of country B. Does country A violates the laws of war by installing this machine?
EDIT: in both cases, I assume that everyone in country B knows about this automatic system. So when militants in country B shoot at country A, they knowingly trigger the counter-shoot at their own citizens. My argument is that, although the international law is violated, the violators are the militants from country B who trigger the shoot - not country A who placed the system in advance. Is this reasoning correct?