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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copy to .env and fill in. Never commit .env.
# Required iff CALIPER_PROVIDER=gemini (the default).
GEMINI_API_KEY=AIza...
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
enable-cache: true
- name: Sync dependencies
run: uv sync --locked
- name: Lint
run: uv run ruff check .
- name: Format check
run: uv run ruff format --check .
- name: Type check
run: uv run mypy src/caliper
- name: Test
run: uv run pytest
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Local runtime data (ARCHITECTURE §6.3 — never committed)
data/caliper.db
data/*.db
data/backup.db
data/cache/
data/feedback_export.csv

# User config and secrets
caliper.toml
.env

# Python
.venv/
__pycache__/
*.py[cod]
*.egg-info/
.pytest_cache/
.mypy_cache/
.ruff_cache/
dist/
build/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
86 changes: 86 additions & 0 deletions docs/TASKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Caliper — Task Tracker

Source of truth for the task definitions: `docs/ARCHITECTURE.md` §14.2 (task breakdown), §14.3 (parallelization map). This file only tracks status; the definitions below are summaries — the architecture document is binding.

**Working agreement (hold-after-every-task):** one task per cycle — implement, verify acceptance criteria, commit, move the task to **Done** with the commit hash, then STOP for review. No task starts before its reviewer approves the previous one and the task's dependencies are Done.

Statuses: ✅ done · 🔄 doing · ⬜ remaining · ✂️ cut (stretch only, per the P5 cut order: FR-13 first, then FR-12)

---

## Done

| ID | Commit(s) | Verified |
|---|---|---|
| T01 | `c76a2bc` (tracker), `d0446f6` (scaffold) | `uv sync` OK (CPython 3.12.16); `uv run caliper --help` renders; `ruff check` + `ruff format --check` + `mypy` clean; 2 tests pass. *CI run on GitHub pending — first push.* |

## Doing

_(none — next up: **T02**, pending review)_

## Remaining

### P0 — Foundation

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T02 | Config + fingerprint | `src/caliper/config.py`, `configs/caliper.sample.toml`, `configs/v1.toml`, `configs/v2.toml`, `configs/v3.toml` | T01 | Load merges user+preset; fingerprint stable on identical inputs, changes on every §7.8-listed field change; invalid config rejected with key path |
| T03 | Schema + db accessors | `src/caliper/schema.sql`, `src/caliper/db.py` | T02 | `ensure_schema` idempotent; append-only triggers raise on UPDATE/DELETE of `runs`, `run_results`, `spot_checks`, `feedback`; `connect` loads sqlite-vec on Windows; accessors unit-tested |
| T04 | Providers + live smoke test | `src/caliper/providers/*`, `scripts/smoke.py`, `tests/fakes.py` | T02 | `smoke.py` completes one chat call + one 768-dim embed per backend, demonstrates normalization, logs a 429 backoff; OQ1 verified and decision logged |

### P1 — Ingestion

| 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 |

### P2 — Ask path

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T09 | Retrieval core | `src/caliper/retrieval/__init__.py` | T03, T04 | `vector` mode returns exactly 5 passages with cosine scores; deterministic on fixed input |
| T10 | RRF fusion | `src/caliper/retrieval/fuse.py` | T09 | RRF of two ranked lists matches the textbook formula on fixture vectors; `hybrid_rrf` wired behind config |
| T11 | Answer + quotes + confidence | `src/caliper/answer/*` | T09 | Refusal on out-of-scope fixture question, no hallucinated citations; quote verifier passes/retries/drops per §7.7; confidence rules unit-tested; full trace persisted |

### P3 — Evaluation

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T12 | Ask CLI + logging | `src/caliper/cli.py` (ask) | T11 | `caliper ask --json` matches §9.2 schema; every call writes `requests` + children with latency/tokens/cost |
| T13 | Golden loader | `src/caliper/eval/golden.py`, `data/golden/GOLDEN.md` | T03 | Rejects tampered file (hash), wrong composition, duplicate IDs |
| T14 | Eval harness + metrics + report fragment | `src/caliper/eval/__init__.py`, `metrics.py`, `report.py` | T12, T13 | 60-question fake run produces all §9.6 metrics incl. median/p95; fingerprint mismatch aborts before any run row; two runs coexist append-only |
| T15 | Spot-check tooling | `src/caliper/eval/spotcheck.py` | T14 | Deterministic seeded sample of 20 answerable questions; judgments append-only; metrics use latest judgment |
| T16 | V1 baseline run | `docs/EVALUATION.md` (initial), run records in `data/caliper.db` | T08, T14, T15 + real corpus | Run v1 complete on real corpus; refusal threshold re-verified once and frozen; results committed. **Reviewer gate: golden set freeze verified before run starts** |

### P4 — Versions

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T17 | V2 segmentation run | `configs/v2.toml`, re-ingest, run records | T16 | v2 index coexists with v1 (per-fingerprint tables); prior traces still reconstructable |
| T18 | V3 reranker + run | optional dep group in `pyproject.toml`, `src/caliper/retrieval/` rerank wiring, run records | T17 | Cross-encoder reranks top-20→5; v3 run recorded; deltas vs v2 visible |
| T19 | Comparison table | `docs/EVALUATION.md`, `caliper report` | T16–T18 | One table with all three runs' metrics incl. deltas; generated by command, committed |

### P5 — Stretch (cut order if slipping: FR-13 → FR-12)

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T20 | Ask page | `src/caliper/web/*` (app, routes, templates, `app.js`) | T12 | Browser ask→answer with citations + confidence; refusal path renders; errors render §9 envelope |
| T21 | Review screen + feedback + export | `src/caliper/web/` additions, `caliper report --feedback csv` | T20 | Feedback stored (idempotent), visible on review page, CSV export round-trips |

### P6 — Setup & wrap-up

| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
| T22 | Setup command + docs | `src/caliper/cli.py` (setup, serve), `docs/SETUP.md`, `README.md` | T07, T20 | Fresh clone + sample config + one command → working ask end-to-end |
| T23 | Acceptance sweep + demo notes | `tests/integration/acceptance*.py`, `docs/LIMITATIONS.md` | T19, T22 | Acceptance criteria 1–10 mapped to tests (11 = demo); LIMITATIONS.md complete; stretch delivered-or-cut recorded |

---

## Notes

- Max concurrency: 2 agents; ownership rules in ARCHITECTURE §6.3 keep parallel tasks disjoint.
- Contract-touching tasks follow the shared-file protocol (§14.4): PR touches only the owned file + its tests, updates the binding §7–§9 section in the same change, and names dependent tasks.
- Never edit `data/golden/questions.jsonl` after the first measured run; never commit `data/caliper.db`, `data/cache/`, `caliper.toml`, `.env`.
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[project]
name = "caliper"
version = "0.1.0"
description = "Local question-answering assistant over one frozen documentation set, with measured quality."
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"google-genai~=1.0",
"typer>=0.12",
"pydantic>=2.7",
"numpy>=1.26",
"httpx>=0.27",
"sqlite-vec==0.1.9",
"fastapi>=0.115",
"uvicorn>=0.30",
"jinja2>=3.1",
]

[project.optional-dependencies]
rerank = ["sentence-transformers>=3.0"]

[project.scripts]
caliper = "caliper.cli:app"

[dependency-groups]
dev = [
"pytest>=8.0",
"ruff",
"mypy>=1.10",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/caliper"]

[tool.ruff]
line-length = 100
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "W"]

[tool.mypy]
strict = true
files = ["src/caliper"]

[tool.pytest.ini_options]
testpaths = ["tests"]
3 changes: 3 additions & 0 deletions src/caliper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Caliper: local Q&A over one frozen documentation set, with measured quality."""

__version__ = "0.1.0"
23 changes: 23 additions & 0 deletions src/caliper/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Caliper command surface (skeleton).

Subcommands land with their owning tasks per ARCHITECTURE §14.2:
ingest (T07), ask (T12), eval/report/spotcheck (T14/T15/T19), setup/serve (T22).
The only argument parsing in the project lives here (§7.9).
"""

import typer

app = typer.Typer(
name="caliper",
help="Local Q&A assistant over one frozen documentation set, with measured quality.",
no_args_is_help=True,
)


@app.callback()
def main() -> None:
"""Caliper: ask questions, get cited answers, measure quality."""


if __name__ == "__main__":
app()
18 changes: 18 additions & 0 deletions tests/test_scaffold.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""T01 scaffold smoke test: the package imports and the CLI help renders."""

from typer.testing import CliRunner

from caliper import __version__
from caliper.cli import app

runner = CliRunner()


def test_version_is_defined() -> None:
assert __version__ == "0.1.0"


def test_cli_help_exits_zero() -> None:
result = runner.invoke(app, ["--help"])
assert result.exit_code == 0
assert "Usage:" in result.output
Loading
Loading