I think the fix for the check triggers should be as the attached. Very close to what you did, but you were skipping some operations that needed to be kept. AFAICS this patch works correctly for the posted cases.
After applying the attached, the r_1_p_id_fkey1 will have redundant action
triggers, as below:
postgres=# select oid, conname, contype, conrelid, conindid,conparentid, confrelid,conislocal,coninhcount, connoinherit from pg_constraint where oid = 16402; oid | conname | contype | conrelid | conindid | conparentid | confrelid | conislocal | coninhcount | connoinherit -------+----------------+---------+----------+----------+-------------+-----------+------------+-------------+-------------- 16402 | r_1_p_id_fkey1 | f | 16394 | 16392 | 0 | 16389 | t | 0 | f (1 row)