[ty] Check packed AST index bounds (#27849)
An out-of-range `NodeIndex` in the final packed chunk can read padding
instead of rejecting the lookup. That padding can decode to an address
and node kind that were never recorded together, violating the invariant
used to reconstruct an AST reference.
Check the chunk's actual entry count before decoding either
representation, so invalid lookups fail before reconstructing a
reference.
Co-authored-by: zaniebot <242828183+zaniebot@users.noreply.github.com>