Fix atomic reindex repair metadata after PR 86 - #89
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9759c55c5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| indexing_v3_agent_status: "pending", | ||
| indexing_v3_agent_last_error: coreAgentMessage, | ||
| indexing_v3_agent_repair_reason: "core_index_committed", | ||
| indexing_v3_agent_updated_at: indexedAt, |
There was a problem hiding this comment.
Reset stale v3 retry state for fresh generations
When atomically reindexing a document whose existing metadata has an exhausted indexing_v3_agent_attempt_count/indexing_v3_agent_max_attempts pair or a future indexing_v3_agent_next_run_at, this new pending marker still inherits those stale fields from job.documents.metadata; claim_indexing_v3_agent_jobs filters on attempt_count < max_attempts and next_run_at <= now, so if the worker stops after the core-generation commit, the fresh generation remains unclaimable despite being marked pending. Clear/reset the retry and schedule fields alongside the fresh pending status.
Useful? React with 👍 / 👎.
| indexing_v3_agent_status: "pending", | ||
| indexing_v3_agent_last_error: coreAgentMessage, | ||
| indexing_v3_agent_repair_reason: "core_index_committed", | ||
| indexing_v3_agent_updated_at: indexedAt, |
There was a problem hiding this comment.
Delay v3 agent visibility until metadata rewrites finish
When the cron claims this document after commitDocumentIndexGeneration returns but before processJob reaches the later whole-metadata updateDocument (especially while WORKER_INLINE_ENRICHMENT=true is still enriching), claim_indexing_v3_agent_jobs can set the v3 agent lock/status to processing; the local worker then writes its precomputed finalMetadata and erases that lock/attempt state, allowing the same document to be claimed again while local and edge enrichment race over the same artifacts. Avoid making the row claimable until the local worker is done rewriting metadata, or preserve any intervening agent claim.
Useful? React with 👍 / 👎.
Summary
Verification
No dependency versions were changed.