Skip to content

Wire async batch submit into the ingest loop (follow-up to #420 part 1) #430

Description

@CheeryProgrammer

Follow-up to #420 part 1, which shipped the submit/poll/apply machinery (SubmitExtractionBatch, PollExtractionBatches, kb poll-batches, the extraction_batch_items mapping, BatchExtractor wiring). What remains is the ingest integration:

When EXTRACTION_BATCH is enabled (with the Claude extractor), the ingest extractor loop should, instead of calling extractChunk synchronously per hot chunk, collect BatchWorkItems (custom_id, text, source_uri, discriminators, forceReview) across the document (or the run) and call SubmitExtractionBatch once — so a large backfill submits one cheap batch and kb poll-batches (cron) drains it later, rather than paying per-chunk synchronous cost.

Scope

  • In internal/core/ingest.go, when c.batchExtractor != nil, accumulate items from the kept hot chunks and submit a batch after the doc's store tx (chunks must exist first — the mapping references source_uri, and results are applied to the graph, not to chunk rows).
  • Choose custom_id = the chunk's content hash (stable, unique within the batch).
  • Keep the synchronous path when batch is off (default).
  • Report submitted-batch counts in IngestStats.

Tests

DB test: with a mock BatchExtractor, ingest a doc in batch mode → a job + items recorded, no synchronous extraction; then PollExtractionBatches applies.

P2, area:ingestion.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions