Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Statuses: ✅ done · 🔄 doing · ⬜ remaining · ✂️ cut (stretch only, p

## Doing

_(none — next up: **T05** (needs T04) and **T09** (needs T03+T04); parallelizable per §14.3)_
| ID | Branch | Status |
|---|---|---|
| T05 | arch/caliper/t05 | implemented, verification below |

## Remaining

Expand All @@ -35,7 +37,6 @@ _(none — next up: **T05** (needs T04) and **T09** (needs T03+T04); paralleliza

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T05 | Corpus source | `src/caliper/ingest/source.py` | T04 | Tarball fetched once, cached, ref pinned; file→URL mapping unit-tested against 5 known pages; exclusions applied |
| T06 | Parsers + chunkers | `src/caliper/ingest/parse.py`, `src/caliper/ingest/chunkers.py` | T05 | Heading paths correct on fixture corpus; both chunkers hit token bounds; 1,900-token cap enforced |
| T07 | Ingest orchestration | `src/caliper/ingest/__init__.py`, `src/caliper/cli.py` (ingest) | T03, T06 | Double-ingest on mini-corpus yields identical counts; orphan chunks removed; summary JSON matches §9.4 |
| T08 | Embedding batcher + resume | edits within `src/caliper/ingest/` only | T07 | Batch ≤100/request; 429 backoff via providers; interrupt + resume completes without re-embedding finished batches |
Expand Down Expand Up @@ -108,3 +109,10 @@ _(none — next up: **T05** (needs T04) and **T09** (needs T03+T04); paralleliza
- **T04 — OQ1 still open:** free-tier RPD for `gemini-3.5-flash-lite` must be verified live (AI Studio) at the smoke run and logged in §18.
- **T04 — live smoke result (2026-11-16):** Gemini leg PASSED live — chat OK on `gemini-3.5-flash-lite` (26/18 tokens), embed OK 768-dim norm 1.000000, cost estimated from `prices.json`, 429 backoff demo logged. Ollama leg deferred: Ollama not installed; re-run `uv run python scripts/smoke.py` after `ollama pull qwen2.5:7b-instruct` + `nomic-embed-text`. User decision recorded 2026-11-16.
- **T04 — bug found by the live smoke:** google-genai's `Models` holds only a weak reference to its `Client`; dropping the Client fails every request ("client has been closed"). Fixed in `89e5423`: `GeminiSession` owns the `genai.Client`, factories and smoke pass it to the backends (`keepalive` slot). This would have broken the production ask path at T11/T12 — worth remembering when reading T04's diff.
- **T05 — `ingest/__init__.py` marker ownership:** T05 created `src/caliper/ingest/__init__.py` as an empty package marker (one docstring line, no code) so `caliper.ingest.source` is importable. §14.2 assigns this file to T07 — it remains T07-owned from here on; T05 made no other change to it.
- **T05 — cache dir source:** `CaliperConfig` (T02, `extra="forbid"`, fingerprint-relevant fields only per §11.2) has no cache-dir field, so `fetch_corpus`/`read_cache_meta` read `CALIPER_CACHE_DIR` directly, default `data/cache` (§11.2); constants `CACHE_DIR_ENV_VAR`/`DEFAULT_CACHE_DIR` live in `source.py`. No `config.py` edit was made (forbidden for T05); if a field is ever added, `_cache_dir` should prefer it over the env var.
- **T05 — public API frozen for T06/T07:** `fetch_corpus(cfg, *, refresh=False, fetcher=None) -> Path`; `read_cache_meta(cfg) -> CacheMeta` (frozen dataclass `branch`/`sha`/`source_ref`/`fetched_at` — T07 reads it for the §9.4 summary instead of re-resolving the ref); `format_source_ref(sha) -> str` (`main@<7-char sha>`); `page_to_url(rel_path) -> str`; `discover_pages(extracted_root) -> list[str]` (sorted, forward-slash, corpus-relative, exclusions applied); `SourceError`; constants `AZURE_DOCS_REPO`, `AZURE_DOCS_BRANCH`, `ARTICLE_TREES`, `LEARN_BASE_URL`, `HTTP_TIMEOUT_S`; type alias `Fetcher = Callable[[str], bytes]`. `fetch_corpus` performs no DB writes (§7.4) and extracts nothing — extraction/chunking starts at T06/T07.
- **T05 — fetcher seam design:** one seam serves both network steps (GitHub ref resolution via `commits_api_url()` and the tarball download via `tarball_url(sha)`): `Callable[[str], bytes]` returning raw bodies, injected through `fetch_corpus`'s public `fetcher` parameter, defaulting to an httpx GET. The test fake (`FakeFetcher` in `tests/unit/test_source.py`) is a test-local constructor-injected double in the same style as the provider tests' `FakeGeminiModels`; `tests/fakes.py` (T04-owned) is untouched, and tests pin the wire URLs as literals. No `patch()`/monkeypatch of internals anywhere (§15); monkeypatch is used only for env/cwd isolation, mirroring `test_providers_base.py`.
- **T05 — cache layout + pin semantics:** `<CALIPER_CACHE_DIR>/azure-docs/<40-hex-sha>.tar.gz` plus a per-branch pin pointer `<CALIPER_CACHE_DIR>/azure-docs/main.json` (`branch`, `sha`, `source_ref`, `fetched_at`), written atomically (tmp + `os.replace`). Cache hit = pointer + tarball both present ⇒ zero network calls and the pin stays the first-fetch ref (fulfilling "pinned ref recorded at first ingest"); corrupt pointer raises `SourceError` (loud, never silently refetched); pointer with missing tarball is a repairable miss; a sha-keyed tarball already on disk is reused without redownload. Distinct refs coexist (keyed by sha); `refresh=True` re-resolves + refetches and re-points.
- **T05 — mapping/exclusion decisions:** `page_to_url` normalizes `\` → `/` and accepts nested slugs under the two trees (Learn mirrors the docs path); it rejects only out-of-tree paths, non-`.md` extensions, and empty slugs — `_`/`includes` filtering is `discover_pages`' job (segment-based, so a filename like `includes-guide.md` is kept). `discover_pages` raises `SourceError` when the root or either article tree is missing — that is the A1-failure signal for the `_fetch_via_toc_api` fallback seam, which stays deliberately unimplemented (`NotImplementedError`). The 5 URL-mapping test pages (`functions-timer`, `functions-bindings-timer`, `functions-create-first-function-vscode`, `service-bus-messaging-overview`, `service-bus-queues-topics-subscriptions`) are mapping tests per the T05 spec, not existence tests; the first two are the slugs already used in ARCHITECTURE §8 examples.
- **T05 — extraction contract handed to T07:** the upstream tarball has one top-level `azure-docs-<sha>/` directory (mirrored by the test fixtures); T07 must strip it and pass the inner root — the directory containing `articles/` — to `discover_pages`.
1 change: 1 addition & 0 deletions src/caliper/ingest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""`ingest` component package (§7.4) — T05 marker only; implementation lands with T07."""
Loading
Loading