fix(indexing): do not commit a chunk count the index did not take (#16261) to release v4.8

Merged
DA
4d ago
+125-3

Cherry-pick of commit 1b79bac01fec144cd05d0134f074d4876a6948ac to release/v4.8 branch.

Original PR: #16261

  • [Optional] Override Linear Check

Summary by cubic

Fixes indexing so documents and user files that fail during embedding or the vector-db write are no longer committed as if they were successfully indexed.

  • The new chunk count was written for every updatable document even when its write failed, so the row described an index state that does not exist and sweeps keyed on the outdated count skipped those docs. The count is now written only for writes the index confirmed, matching the existing content-hash rule.
  • Failed user files were previously marked COMPLETED, had plaintext stored, and triggered assistant-ready notifications that the caller's failure handling cannot take back. They are now skipped so the caller can fail them.