The problem
A list with more than one embedding field double-writes on generation.
RAG generates in an afterTransaction hook and protects against re-entry by comparing the stored source hash: the sudo write names only the embedding column, so its own re-entrant pass sees an unchanged hash and returns. That reasoning holds for one field. With two embedding fields on the same list, each sudo write re-enters the hook, and the other field's pass has no stored hash yet, so it writes again.
The result is redundant provider calls and redundant writes, growing with the number of embedding fields on the list.
Why it is latent today
The secured write surface does not execute at all on prisma-8 — write-pipeline.ts still speaks Prisma 6 — so the sudo write currently fails before any of this can happen. This becomes live the moment #1124 lands.
What to do
Make the re-entry protection independent of how many embedding fields a list has. Either mark the sudo write so the hook can recognise its own re-entry directly, or generate every embedding field for a row in one pass rather than one write per field.
The acceptance test is a list with two embedding fields producing exactly one provider call per field per source change.
Context
Generated by Claude Code
The problem
A list with more than one embedding field double-writes on generation.
RAG generates in an
afterTransactionhook and protects against re-entry by comparing the stored source hash: the sudo write names only the embedding column, so its own re-entrant pass sees an unchanged hash and returns. That reasoning holds for one field. With two embedding fields on the same list, each sudo write re-enters the hook, and the other field's pass has no stored hash yet, so it writes again.The result is redundant provider calls and redundant writes, growing with the number of embedding fields on the list.
Why it is latent today
The secured write surface does not execute at all on
prisma-8—write-pipeline.tsstill speaks Prisma 6 — so the sudo write currently fails before any of this can happen. This becomes live the moment #1124 lands.What to do
Make the re-entry protection independent of how many embedding fields a list has. Either mark the sudo write so the hook can recognise its own re-entry directly, or generate every embedding field for a row in one pass rather than one write per field.
The acceptance test is a list with two embedding fields producing exactly one provider call per field per source change.
Context
Generated by Claude Code