Skip to content

feat(ingest): orchestration with idempotent chunk diff and summary json (T07) - #12

Merged
prateekchaplot merged 2 commits into
mainfrom
arch/caliper/t07
Nov 17, 2026
Merged

prateekchaplot merged 2 commits into
mainfrom
arch/caliper/t07

Conversation

@prateekchaplot

Copy link
Copy Markdown
Owner

Task T07 — Ingest orchestration

Implements T07 from docs/ARCHITECTURE.md §14.2 (spec: §7.4, §9.4, §10.3). Deps T03 + T06 are Done.

What it does

  • run_ingest(cfg, *, refresh=False, fetcher=None, embeddings=None) -> IngestSummary in src/caliper/ingest/__init__.py: fetch (pinned-ref cache) → extract (strips the upstream top-level azure-docs-<sha>/ dir, T05's handoff) → parse → chunk (T06's frozen API) → chunk_hash = SHA-256(normalized body + url + heading path) (NUL-joined fields) → insert/orphan diff against the stored index (re-ingest upserts changed chunks, deletes disappeared pages — FR-02 idempotency) → embed inserted chunks in batches of ≤100 via the backend (429 backoff lives inside the providers, T04) → store normalized vectors in chunks_<fp8>_vec → record the completed run in ingest_runs with the §9.4 summary JSON.
  • caliper ingest --version v1|v2|v3 [--refresh] in src/caliper/cli.py: prints the §9.4 summary JSON on stdout; maps typed errors to the §9 envelope once (config_invalid→2, provider_unavailable→4, quota_exhausted→5; SourceError/DbError→4 — recorded in TASKS Notes, §9 has no local-infrastructure code).
  • ARCHITECTURE §7.4 updated (shared-file protocol, §14.4): names the frozen CHARS_PER_TOKEN = 4 token estimator (paying off T06's recorded deviation) and the chunk-hash normalization definition T08 re-derives. Dependent tasks: T08 (resume/checkpoint on this diff + hash), T22 (setup runs ingest).

Verification

  • uv run pytest — 240 passed (223 prior + 17 new: tests/unit/test_ingest_hash.py for the hash contract + §9.4 shape; tests/integration/test_ingest.py covering the task's acceptance criteria: double-ingest on a mini-corpus yields identical index state with 0 writes/0 embeds on run 2, orphan chunks removed with FTS/vec tables kept in sync, summary JSON matches §9.4 incl. skip reasons, batch bound ≤100, tarball-layout failure is loud).
  • uv run ruff check + uv run ruff format --check + uv run mypy (strict) — clean.
  • uv run caliper ingest --help renders (manual check).

Deviations / decisions (all recorded in docs/TASKS.md Notes)

  • chunks_written/chunks_removed are per-run action counts; "double-ingest yields identical counts" is asserted as identical index state + stable pages_* fields.
  • Summary fingerprint is the 8-hex fp8 (matches the §9.4 example); the full fingerprint goes in the DB rows.
  • ingest_runs upsert+finish happen at completion (§10.3's final step) — a crashed ingest leaves the prior completed row; resume checkpoints are T08's job.

…on (T07)

run_ingest(cfg) wires fetch -> extract -> parse -> chunk -> hash -> diff ->
embed -> summarize per ARCHITECTURE 7.4/10.3: chunk_hash = SHA-256 of the
normalized body + url + heading path (NUL-joined) drives the insert/orphan
diff that makes double-ingest idempotent (FR-02/A8); inserted chunks embed in
batches of <=100 via the provider backends' own 429 backoff; the 9.4 summary
is returned and stored in ingest_runs. caliper ingest --version v1|v2|v3
[--refresh] prints the summary JSON and maps typed errors to the 9 envelope
(exit 2/4/5). ARCHITECTURE 7.4 now names the CHARS_PER_TOKEN=4 estimator
(paying off T06's recorded deviation) and the hash normalization T08 re-derives.
@prateekchaplot
prateekchaplot merged commit 4b4b5c9 into main Nov 17, 2026
1 check passed
@prateekchaplot
prateekchaplot deleted the arch/caliper/t07 branch November 17, 2026 16:44
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