Skip to content

feat(core): async batch-extraction submit/poll/apply + kb poll-batches (#420 part 1) - #432

Merged
CheeryProgrammer merged 2 commits into
mainfrom
feat/420-batch-apply
Jul 19, 2026
Merged

feat(core): async batch-extraction submit/poll/apply + kb poll-batches (#420 part 1)#432
CheeryProgrammer merged 2 commits into
mainfrom
feat/420-batch-apply

Conversation

@CheeryProgrammer

Copy link
Copy Markdown
Contributor

What & why

Part of #420 (ingestion). Turns #383's batch infrastructure into a working submit → apply pipeline. Opt-in — nothing runs by default.

How

  • applyExtraction is factored out of extractChunk, so the synchronous path and the batch poller share one graph-apply.
  • BatchExtractor interface (satisfied by the anthropic Extractor; wired via WithBatchExtractor when EXTRACTION_BATCH + Claude).
  • SubmitExtractionBatch(items) calls CreateBatch, records the job (Wire BatchExtractor into an async ingest job + cross-doc entity resolution (follow-up to #326) #383) + a new extraction_batch_items mapping (migration 0024: custom_id → source_uri / discriminators / force_review).
  • kb poll-batches (PollExtractionBatches) checks each submitted job's FetchBatchResults; once ended it applies each succeeded result to the graph via applyExtraction keyed by custom_id (honoring scope + trust), then marks the job applied. Best-effort per item — a missing result is a failed extraction.

Tests (DB-gated, CI)

TestBatchExtractionSubmitAndPoll (mock BatchExtractor): submit records job + items; poll applies nothing while processing, then applies nodes/edges once ended and marks the job applied. TestMigrate covers the new table. gofmt/vet/golangci-lint clean. SYSTEM.md (§10) + .env.example updated.

Not in this PR

Wiring the submit into the ingest loop (batch instead of sync extract) is #430; cross-doc entity resolution is #431.

🤖 Generated with Claude Code

CheeryProgrammer and others added 2 commits July 19, 2026 22:47
#420 part 1)

Turns #383's batch infrastructure into a working submit->apply pipeline.

- applyExtraction is factored out of extractChunk, so the synchronous
  path and the batch poller share one graph-apply.
- BatchExtractor interface (satisfied by the anthropic Extractor; wired
  via WithBatchExtractor when EXTRACTION_BATCH + Claude).
- SubmitExtractionBatch(items) calls CreateBatch, records the job (#383)
  + a new extraction_batch_items mapping (migration 0024: custom_id ->
  source_uri / discriminators / force_review).
- kb poll-batches (PollExtractionBatches) checks each submitted job's
  FetchBatchResults; once ended it applies each succeeded result to the
  graph via applyExtraction keyed by custom_id (honoring scope + trust),
  then marks the job applied. Best-effort per item — a missing result is
  a failed extraction.

Opt-in, nothing runs by default. Wiring the submit into the ingest loop
(batch instead of sync extract) is follow-up #430; cross-doc entity
resolution is #431.

Tests: TestBatchExtractionSubmitAndPoll (DB + mock BatchExtractor) —
submit records job+items; poll applies nothing while processing, applies
nodes/edges once ended and marks the job applied. TestMigrate covers the
new table. SYSTEM.md + .env.example updated.

Part of #420

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nces it

Migration 0024 added extraction_batch_items with a FK to
extraction_batches, so TestExtractionBatchJobStore's plain TRUNCATE fails
(SQLSTATE 0A000). Add CASCADE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CheeryProgrammer
CheeryProgrammer merged commit a8fe058 into main Jul 19, 2026
5 checks passed
@CheeryProgrammer
CheeryProgrammer deleted the feat/420-batch-apply branch July 19, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant