Hydrating a self-referential one-to-many relation (e.g. ThreadPost.replies :
[ThreadPost]) attached live store-row references that, since sibling rows
reference each other, formed object cycles — res.json() then threw
'Converting circular structure to JSON' → HTTP 500. Attach shallow clones and,
for the self-referential case, neutralize the child's own back-pointer field so
hydrated children are leaves (one level of hydration, no cycle).
Also narrow EntityField via its discriminant before reading .relation in
schema-to-ir (the canonical EntityField union only exposes relation on the
relation variant) — unblocks tsc.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>