I found that all the sub-statements in a statement, for example statement in WITH clause and outside it, should be assigned the same cid to maintain visibility. In the case of XC, they may be divided into multiple statements, where we should provide the same visibility.
To do this, we may need a feature to maintain the same "cid" among multiple sub-statements derived from the original statement.
David Fetter's lecture on CTE in PGCon2011 helped much. Thank you David.