Repository navigation
feat(ingest): orchestration with idempotent chunk diff and summary json (T07) - #12
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) -> IngestSummaryinsrc/caliper/ingest/__init__.py: fetch (pinned-ref cache) → extract (strips the upstream top-levelazure-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 inchunks_<fp8>_vec→ record the completed run iningest_runswith the §9.4 summary JSON.caliper ingest --version v1|v2|v3 [--refresh]insrc/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).CHARS_PER_TOKEN = 4token 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.pyfor the hash contract + §9.4 shape;tests/integration/test_ingest.pycovering 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 --helprenders (manual check).Deviations / decisions (all recorded in docs/TASKS.md Notes)
chunks_written/chunks_removedare per-run action counts; "double-ingest yields identical counts" is asserted as identical index state + stablepages_*fields.fingerprintis the 8-hexfp8(matches the §9.4 example); the full fingerprint goes in the DB rows.ingest_runsupsert+finish happen at completion (§10.3's final step) — a crashed ingest leaves the prior completed row; resume checkpoints are T08's job.