raglab 0.2.12__tar.gz → 0.2.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,7 +77,6 @@ instance/
77
77
 
78
78
  # Sphinx documentation
79
79
  docs/_build/
80
- docs/*
81
80
 
82
81
  # PyBuilder
83
82
  target/
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: raglab
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: A medley of tools to make RAG-based applications.
5
- Project-URL: Homepage, https://thorwhalen.github.io/raglab/
6
- Project-URL: Repository, https://github.com/thorwhalen/raglab
7
- Project-URL: Documentation, https://thorwhalen.github.io/raglab
8
- Project-URL: Issues, https://github.com/thorwhalen/raglab/issues
9
- Project-URL: Changelog, https://github.com/thorwhalen/raglab/blob/main/CHANGELOG.md
5
+ Project-URL: Homepage, https://addaix.github.io/raglab/
6
+ Project-URL: Repository, https://github.com/addaix/raglab
7
+ Project-URL: Documentation, https://addaix.github.io/raglab
8
+ Project-URL: Issues, https://github.com/addaix/raglab/issues
9
+ Project-URL: Changelog, https://github.com/addaix/raglab/blob/main/CHANGELOG.md
10
10
  Author: thorwhalen
11
11
  License-Expression: MIT
12
12
  License-File: LICENSE
@@ -36,12 +36,7 @@ Description-Content-Type: text/markdown
36
36
 
37
37
  The **agentic-search / RAG orchestration layer on top of [`ir`](https://github.com/i2mint/ir)** (the retrieval substrate).
38
38
 
39
- `raglab` turns a retrieval substrate into a **Composable Search Agent**: a small
40
- set of injected **roles** — Planner, Formulator, Retriever, Evaluator, Reranker,
41
- Citer — wired by a control loop. The loop's defining feature is the **back-edge**
42
- (*evaluator → reformulate*): when results aren't good enough, the agent rewrites
43
- the query and searches again. That back-edge is what makes it an *agent* rather
44
- than a fixed pipeline (DAG).
39
+ `raglab` turns a retrieval substrate into a **Composable Search Agent**: a small set of injected **roles** — Planner, Formulator, Retriever, Evaluator, Reranker, Citer — wired by a control loop. The loop's defining feature is the **back-edge** (*evaluator → reformulate*): when results aren't good enough, the agent rewrites the query and searches again. That back-edge is what makes it an *agent* rather than a fixed pipeline (DAG).
45
40
 
46
41
  ```bash
47
42
  pip install raglab
@@ -57,10 +52,9 @@ pip install raglab
57
52
 
58
53
  ## Quick start
59
54
 
60
- The default agent runs **fully offline** — no LLM, no network. Point it at one or
61
- more `ir` corpora and call it like a function; you get back ranked
62
- [`ir.SearchHit`](https://github.com/i2mint/ir)s.
55
+ The default agent runs **fully offline** — no LLM, no network. Point it at one or more `ir` corpora and call it like a function; you get back ranked [`ir.SearchHit`](https://github.com/i2mint/ir)s.
63
56
 
57
+ <!-- wads-docs: skip needs registered ir corpora and an LLM key -->
64
58
  ```python
65
59
  import ir
66
60
  import raglab
@@ -94,10 +88,7 @@ results = agent("deploy the app to the server")
94
88
  results[0].artifact_id # -> "deploy"
95
89
  ```
96
90
 
97
- `sources` is any `Mapping[name, Retriever]`. Build it with
98
- [`raglab.ir_sources(*names, **defaults)`](#sources), with `ir.retrievers()` (a
99
- lazy live view over everything ir has registered), or by hand:
100
- `{"skills": ir.as_retriever("skills")}`.
91
+ `sources` is any `Mapping[name, Retriever]`. Build it with [`raglab.ir_sources(*names, **defaults)`](#sources), with `ir.retrievers()` (a lazy live view over everything ir has registered), or by hand: `{"skills": ir.as_retriever("skills")}`.
101
92
 
102
93
  ---
103
94
 
@@ -117,10 +108,7 @@ lazy live view over everything ir has registered), or by hand:
117
108
  Reranker (fan-in) → Citer → ranked results
118
109
  ```
119
110
 
120
- The **loop is fixed**; every *decision* in it is an injected **role** (a plain
121
- callable satisfying a `Protocol`). v1 ships every role with a sensible default,
122
- so the simple path — `make_search_agent(sources)("query")` — just works. You turn
123
- capabilities on by swapping in richer roles.
111
+ The **loop is fixed**; every *decision* in it is an injected **role** (a plain callable satisfying a `Protocol`). v1 ships every role with a sensible default, so the simple path — `make_search_agent(sources)("query")` — just works. You turn capabilities on by swapping in richer roles.
124
112
 
125
113
  | Role | Decides | Default (no-LLM) | Inject an LLM version to… |
126
114
  |------|---------|------------------|---------------------------|
@@ -131,17 +119,15 @@ capabilities on by swapping in richer roles.
131
119
  | **Reranker** | final cross-source ordering (fan-in) | `rrf_reranker` (rank fusion) | weight sources, change fusion |
132
120
  | **Citer** | confirm each result supports its use | `identity_citer` (no-op) | *(generation/verification lives in `srag`)* |
133
121
 
134
- **`Budget`** bounds the loop (`max_rounds`, `max_sources_per_task`,
135
- `max_results_per_task`) — the safety net under the (harder) sufficiency decision.
122
+ **`Budget`** bounds the loop (`max_rounds`, `max_sources_per_task`, `max_results_per_task`) — the safety net under the (harder) sufficiency decision.
136
123
 
137
124
  ---
138
125
 
139
126
  ## Turning on query understanding and the back-edge
140
127
 
141
- Inject the two LLM roles to upgrade the offline slice into a real agent. Both
142
- build their model lazily on [`oa`](https://github.com/thorwhalen/oa) **only when
143
- invoked**, so `import raglab` stays offline.
128
+ Inject the two LLM roles to upgrade the offline slice into a real agent. Both build their model lazily on [`oa`](https://github.com/thorwhalen/oa) **only when invoked**, so `import raglab` stays offline.
144
129
 
130
+ <!-- wads-docs: skip needs registered ir corpora and an LLM key -->
145
131
  ```python
146
132
  import raglab
147
133
 
@@ -155,34 +141,18 @@ results = agent("how do I deploy the app")
155
141
 
156
142
  How the Evaluator splits the decision (a load-bearing boundary):
157
143
 
158
- - **Relevance is `ir`'s.** Each round the accumulated hits pass through
159
- `ir.select` (default strategy `"conservative"` — distractor-robust); the
160
- committed subset becomes `Judgement.relevant`. LLM relevance scoring is
161
- known-fragile, so the LLM stays out of it.
162
- - **Sufficiency is the LLM's.** Informed by ir's model-free
163
- `Selection.sufficient` hint, the judge decides whether the committed subset
164
- actually satisfies the goal. If not, it emits an improved query — a
165
- `refinement` `SubTask` over the same sources. **That refinement is the
166
- back-edge.**
167
-
168
- Both builders accept an injectable double (`formulate=` / `judge=`) for
169
- deterministic tests, and both **fail safe**: a formulator error falls back to the
170
- raw query (never makes retrieval worse); a judge error returns no refinement
171
- (the loop's break condition — a failing judge can never spin forever).
144
+ - **Relevance is `ir`'s.** Each round the accumulated hits pass through `ir.select` (default strategy `"conservative"` — distractor-robust); the committed subset becomes `Judgement.relevant`. LLM relevance scoring is known-fragile, so the LLM stays out of it.
145
+ - **Sufficiency is the LLM's.** Informed by ir's model-free `Selection.sufficient` hint, the judge decides whether the committed subset actually satisfies the goal. If not, it emits an improved query — a `refinement` `SubTask` over the same sources. **That refinement is the back-edge.**
146
+
147
+ Both builders accept an injectable double (`formulate=` / `judge=`) for deterministic tests, and both **fail safe**: a formulator error falls back to the raw query (never makes retrieval worse); a judge error returns no refinement (the loop's break condition — a failing judge can never spin forever).
172
148
 
173
149
  ---
174
150
 
175
151
  ## Multi-source search and the fan-in reranker
176
152
 
177
- The agent is **multi-source by default**. The loop stamps each hit's provenance
178
- (`hit.source`), and the default fan-in reranker, `rrf_reranker`, merges
179
- heterogeneous sources **by rank, never by raw score**.
153
+ The agent is **multi-source by default**. The loop stamps each hit's provenance (`hit.source`), and the default fan-in reranker, `rrf_reranker`, merges heterogeneous sources **by rank, never by raw score**.
180
154
 
181
- This matters because scores from different corpora / embedders / retrieval modes
182
- are *incommensurable* — a cosine score (~0–1) and a BM25 score (~0–50) cannot be
183
- compared directly. Reciprocal Rank Fusion (RRF) sidesteps this: within one source
184
- raw scores order and dedup that source's hits (one scale, sound); across sources
185
- only **ranks** interact.
155
+ This matters because scores from different corpora / embedders / retrieval modes are *incommensurable* — a cosine score (~0–1) and a BM25 score (~0–50) cannot be compared directly. Reciprocal Rank Fusion (RRF) sidesteps this: within one source raw scores order and dedup that source's hits (one scale, sound); across sources only **ranks** interact.
186
156
 
187
157
  ```python
188
158
  # Two sources on different score scales:
@@ -192,9 +162,7 @@ only **ranks** interact.
192
162
  agent = raglab.make_search_agent(sources, reranker=raglab.score_reranker)
193
163
  ```
194
164
 
195
- Colliding `artifact_id`s from different sources stay distinct (identity is
196
- `(source, artifact_id)`). Each fused hit keeps its pre-fusion magnitude in
197
- `metadata["source_score"]`. For per-source trust weights or a custom `rrf_k`:
165
+ Colliding `artifact_id`s from different sources stay distinct (identity is `(source, artifact_id)`). Each fused hit keeps its pre-fusion magnitude in `metadata["source_score"]`. For per-source trust weights or a custom `rrf_k`:
198
166
 
199
167
  ```python
200
168
  reranker = raglab.make_rrf_reranker(weights={"skills": 2.0, "web": 0.5}, rrf_k=60)
@@ -226,10 +194,7 @@ def my_formulator(task, source):
226
194
  agent = make_search_agent(sources, planner=my_planner, formulator=my_formulator)
227
195
  ```
228
196
 
229
- A **custom Retriever** is any `callable(query, **params) -> Sequence[ir.SearchHit]`.
230
- It must return `ir.SearchHit` instances (the `Result` alias) — the loop stamps
231
- provenance on its output, so duck-typed hit objects raise at the tagging step.
232
- ir-backed retrievers self-attribute their corpus name.
197
+ A **custom Retriever** is any `callable(query, **params) -> Sequence[ir.SearchHit]`. It must return `ir.SearchHit` instances (the `Result` alias) — the loop stamps provenance on its output, so duck-typed hit objects raise at the tagging step. ir-backed retrievers self-attribute their corpus name.
233
198
 
234
199
  ---
235
200
 
@@ -248,8 +213,7 @@ Everything is exported from the top-level `raglab` namespace.
248
213
  | `Budget` | `max_rounds=3`, `max_sources_per_task=4`, `max_results_per_task=50` |
249
214
  | `Result` | alias for `ir.SearchHit` |
250
215
 
251
- **Role Protocols** (the open-closed strategy seams): `Planner`, `Formulator`,
252
- `Retriever` (re-exported from `ir`), `Evaluator`, `Reranker`, `Citer`.
216
+ **Role Protocols** (the open-closed strategy seams): `Planner`, `Formulator`, `Retriever` (re-exported from `ir`), `Evaluator`, `Reranker`, `Citer`.
253
217
 
254
218
  **Orchestrator & builders:**
255
219
 
@@ -259,69 +223,39 @@ Everything is exported from the top-level `raglab` namespace.
259
223
  | `SingleContextAgent` | The orchestrator dataclass: one ReAct-style loop, sequential sub-tasks. |
260
224
  | <a name="sources"></a>`ir_sources(*names, **search_defaults)` | A `{name: Retriever}` registry backed by named ir corpora. |
261
225
 
262
- **Default roles (the no-LLM thin slice):** `single_subtask_planner`,
263
- `identity_formulator`, `passthrough_evaluator`, `score_reranker`, `rrf_reranker`,
264
- `make_rrf_reranker(*, rrf_k, weights, identity)`, `identity_citer`.
226
+ **Default roles (the no-LLM thin slice):** `single_subtask_planner`, `identity_formulator`, `passthrough_evaluator`, `score_reranker`, `rrf_reranker`, `make_rrf_reranker(*, rrf_k, weights, identity)`, `identity_citer`.
265
227
 
266
- **LLM roles:** `make_llm_formulator(*, formulate=None, params=None, **make_kwargs)`,
267
- `make_llm_evaluator(*, judge=None, select_strategy="conservative", select_kwargs=None, prerank=None, prompt=EVALUATION_PROMPT, ...)`,
268
- and the default `EVALUATION_PROMPT` string.
228
+ **LLM roles:** `make_llm_formulator(*, formulate=None, params=None, **make_kwargs)`, `make_llm_evaluator(*, judge=None, select_strategy="conservative", select_kwargs=None, prerank=None, prompt=EVALUATION_PROMPT, ...)`, and the default `EVALUATION_PROMPT` string.
269
229
 
270
230
  ---
271
231
 
272
232
  ## Architecture & boundaries
273
233
 
274
- `raglab` **owns the agent**: the value types, the role Protocols, the control
275
- loop with the back-edge, the budget governor, the source registry, and the
276
- cross-source fan-in.
234
+ `raglab` **owns the agent**: the value types, the role Protocols, the control loop with the back-edge, the budget governor, the source registry, and the cross-source fan-in.
277
235
 
278
- It **consumes from `ir`** (and does not reimplement): `ir.as_retriever` (corpus →
279
- Retriever), `ir.retrievers()` (the live registry view), `ir.make_llm_formulator`
280
- (the query rewriter), `ir.select` + its `Selection.sufficient` signal (relevance
281
- + the sufficiency hint), and `ir.fuse_hits` (RRF). The `Result` type and the
282
- `Retriever` contract are **ir's** (single source of truth).
236
+ It **consumes from `ir`** (and does not reimplement): `ir.as_retriever` (corpus → Retriever), `ir.retrievers()` (the live registry view), `ir.make_llm_formulator` (the query rewriter), `ir.select` + its `Selection.sufficient` signal (relevance
237
+ + the sufficiency hint), and `ir.fuse_hits` (RRF). The `Result` type and the `Retriever` contract are **ir's** (single source of truth).
283
238
 
284
- **Dependency direction is one-way:** `raglab` imports `ir` (and `oa` for the LLM
285
- roles, lazily); **`ir` never imports `raglab`.** Keeping `oa` opt-in is what lets
286
- `import raglab` stay offline.
239
+ **Dependency direction is one-way:** `raglab` imports `ir` (and `oa` for the LLM roles, lazily); **`ir` never imports `raglab`.** Keeping `oa` opt-in is what lets `import raglab` stay offline.
287
240
 
288
- What lives **elsewhere:** answer synthesis / generation and the
289
- Citer/Verifier (which needs a *generated claim* to verify) belong in the
290
- RAG/generation layer (`srag`), not the search agent. raglab's deliverable is
291
- **pointers + extractions**, not an essay.
241
+ What lives **elsewhere:** answer synthesis / generation and the Citer/Verifier (which needs a *generated claim* to verify) belong in the RAG/generation layer (`srag`), not the search agent. raglab's deliverable is **pointers + extractions**, not an essay.
292
242
 
293
- Where it sits in the ecosystem: **`raglab` → `ir` → {`ef`, `vd`}** — `ir` is the
294
- retrieval substrate, `ef` owns embedders/segmenters, `vd` is the vector-store
295
- facade.
243
+ Where it sits in the ecosystem: **`raglab` → `ir` → {`ef`, `vd`}** — `ir` is the retrieval substrate, `ef` owns embedders/segmenters, `vd` is the vector-store facade.
296
244
 
297
245
  ---
298
246
 
299
247
  ## Status & roadmap
300
248
 
301
- Shipped at **0.2.4**: the `SingleContextAgent` control loop with the back-edge,
302
- all six role Protocols, the no-LLM defaults, the LLM Formulator + Evaluator, and
303
- the RRF cross-source fan-in reranker. The roles, value types, and loop are
304
- stable; richer strategies are added behind the same contracts.
249
+ Shipped at **0.2.4**: the `SingleContextAgent` control loop with the back-edge, all six role Protocols, the no-LLM defaults, the LLM Formulator + Evaluator, and the RRF cross-source fan-in reranker. The roles, value types, and loop are stable; richer strategies are added behind the same contracts.
305
250
 
306
- The living roadmap is **[issue #2](https://github.com/thorwhalen/raglab/issues/2)**
307
- (Composable Search Agent on ir, the *ir_09* reference design). Not yet built:
251
+ The living roadmap is **[issue #2](https://github.com/addaix/raglab/issues/2)** (Composable Search Agent on ir, the *ir_09* reference design). Not yet built:
308
252
 
309
- - **Budget governor refinements** — the per-task results cap currently truncates
310
- in arrival order rather than by rank
311
- ([#5](https://github.com/thorwhalen/raglab/issues/5)); termination as a
312
- separately injected policy is planned.
313
- - **PurposeStore** — persistent, purpose-indexed memory overlay
314
- ([#6](https://github.com/thorwhalen/raglab/issues/6)). There is no cross-run
315
- memory today.
316
- - **`MultiAgentAgent`** — one subagent per sub-task/source (breadth-first, ~15×
317
- cost); promotion swaps only the orchestrator, keeping role contracts identical.
253
+ - **Budget governor refinements** — the per-task results cap currently truncates in arrival order rather than by rank ([#5](https://github.com/addaix/raglab/issues/5)); termination as a separately injected policy is planned.
254
+ - **PurposeStore** — persistent, purpose-indexed memory overlay ([#6](https://github.com/addaix/raglab/issues/6)). There is no cross-run memory today.
255
+ - **`MultiAgentAgent`** — one subagent per sub-task/source (breadth-first, ~15× cost); promotion swaps only the orchestrator, keeping role contracts identical.
318
256
 
319
257
  ---
320
258
 
321
259
  ## House style
322
260
 
323
- Functional over OOP; SOLID when OOP; facades, SSOT, dependency injection;
324
- progressive disclosure; keyword-only args beyond the third positional;
325
- `collections.abc` + frozen `dataclass`es; `Protocol`s for the role seams. Tests
326
- are hermetic (fake retrievers, injected LLM doubles) with a few end-to-end checks
327
- over a real `ir` corpus using the light, numpy-only embedder.
261
+ Functional over OOP; SOLID when OOP; facades, SSOT, dependency injection; progressive disclosure; keyword-only args beyond the third positional; `collections.abc` + frozen `dataclass`es; `Protocol`s for the role seams. Tests are hermetic (fake retrievers, injected LLM doubles) with a few end-to-end checks over a real `ir` corpus using the light, numpy-only embedder.
@@ -2,12 +2,7 @@
2
2
 
3
3
  The **agentic-search / RAG orchestration layer on top of [`ir`](https://github.com/i2mint/ir)** (the retrieval substrate).
4
4
 
5
- `raglab` turns a retrieval substrate into a **Composable Search Agent**: a small
6
- set of injected **roles** — Planner, Formulator, Retriever, Evaluator, Reranker,
7
- Citer — wired by a control loop. The loop's defining feature is the **back-edge**
8
- (*evaluator → reformulate*): when results aren't good enough, the agent rewrites
9
- the query and searches again. That back-edge is what makes it an *agent* rather
10
- than a fixed pipeline (DAG).
5
+ `raglab` turns a retrieval substrate into a **Composable Search Agent**: a small set of injected **roles** — Planner, Formulator, Retriever, Evaluator, Reranker, Citer — wired by a control loop. The loop's defining feature is the **back-edge** (*evaluator → reformulate*): when results aren't good enough, the agent rewrites the query and searches again. That back-edge is what makes it an *agent* rather than a fixed pipeline (DAG).
11
6
 
12
7
  ```bash
13
8
  pip install raglab
@@ -23,10 +18,9 @@ pip install raglab
23
18
 
24
19
  ## Quick start
25
20
 
26
- The default agent runs **fully offline** — no LLM, no network. Point it at one or
27
- more `ir` corpora and call it like a function; you get back ranked
28
- [`ir.SearchHit`](https://github.com/i2mint/ir)s.
21
+ The default agent runs **fully offline** — no LLM, no network. Point it at one or more `ir` corpora and call it like a function; you get back ranked [`ir.SearchHit`](https://github.com/i2mint/ir)s.
29
22
 
23
+ <!-- wads-docs: skip needs registered ir corpora and an LLM key -->
30
24
  ```python
31
25
  import ir
32
26
  import raglab
@@ -60,10 +54,7 @@ results = agent("deploy the app to the server")
60
54
  results[0].artifact_id # -> "deploy"
61
55
  ```
62
56
 
63
- `sources` is any `Mapping[name, Retriever]`. Build it with
64
- [`raglab.ir_sources(*names, **defaults)`](#sources), with `ir.retrievers()` (a
65
- lazy live view over everything ir has registered), or by hand:
66
- `{"skills": ir.as_retriever("skills")}`.
57
+ `sources` is any `Mapping[name, Retriever]`. Build it with [`raglab.ir_sources(*names, **defaults)`](#sources), with `ir.retrievers()` (a lazy live view over everything ir has registered), or by hand: `{"skills": ir.as_retriever("skills")}`.
67
58
 
68
59
  ---
69
60
 
@@ -83,10 +74,7 @@ lazy live view over everything ir has registered), or by hand:
83
74
  Reranker (fan-in) → Citer → ranked results
84
75
  ```
85
76
 
86
- The **loop is fixed**; every *decision* in it is an injected **role** (a plain
87
- callable satisfying a `Protocol`). v1 ships every role with a sensible default,
88
- so the simple path — `make_search_agent(sources)("query")` — just works. You turn
89
- capabilities on by swapping in richer roles.
77
+ The **loop is fixed**; every *decision* in it is an injected **role** (a plain callable satisfying a `Protocol`). v1 ships every role with a sensible default, so the simple path — `make_search_agent(sources)("query")` — just works. You turn capabilities on by swapping in richer roles.
90
78
 
91
79
  | Role | Decides | Default (no-LLM) | Inject an LLM version to… |
92
80
  |------|---------|------------------|---------------------------|
@@ -97,17 +85,15 @@ capabilities on by swapping in richer roles.
97
85
  | **Reranker** | final cross-source ordering (fan-in) | `rrf_reranker` (rank fusion) | weight sources, change fusion |
98
86
  | **Citer** | confirm each result supports its use | `identity_citer` (no-op) | *(generation/verification lives in `srag`)* |
99
87
 
100
- **`Budget`** bounds the loop (`max_rounds`, `max_sources_per_task`,
101
- `max_results_per_task`) — the safety net under the (harder) sufficiency decision.
88
+ **`Budget`** bounds the loop (`max_rounds`, `max_sources_per_task`, `max_results_per_task`) — the safety net under the (harder) sufficiency decision.
102
89
 
103
90
  ---
104
91
 
105
92
  ## Turning on query understanding and the back-edge
106
93
 
107
- Inject the two LLM roles to upgrade the offline slice into a real agent. Both
108
- build their model lazily on [`oa`](https://github.com/thorwhalen/oa) **only when
109
- invoked**, so `import raglab` stays offline.
94
+ Inject the two LLM roles to upgrade the offline slice into a real agent. Both build their model lazily on [`oa`](https://github.com/thorwhalen/oa) **only when invoked**, so `import raglab` stays offline.
110
95
 
96
+ <!-- wads-docs: skip needs registered ir corpora and an LLM key -->
111
97
  ```python
112
98
  import raglab
113
99
 
@@ -121,34 +107,18 @@ results = agent("how do I deploy the app")
121
107
 
122
108
  How the Evaluator splits the decision (a load-bearing boundary):
123
109
 
124
- - **Relevance is `ir`'s.** Each round the accumulated hits pass through
125
- `ir.select` (default strategy `"conservative"` — distractor-robust); the
126
- committed subset becomes `Judgement.relevant`. LLM relevance scoring is
127
- known-fragile, so the LLM stays out of it.
128
- - **Sufficiency is the LLM's.** Informed by ir's model-free
129
- `Selection.sufficient` hint, the judge decides whether the committed subset
130
- actually satisfies the goal. If not, it emits an improved query — a
131
- `refinement` `SubTask` over the same sources. **That refinement is the
132
- back-edge.**
133
-
134
- Both builders accept an injectable double (`formulate=` / `judge=`) for
135
- deterministic tests, and both **fail safe**: a formulator error falls back to the
136
- raw query (never makes retrieval worse); a judge error returns no refinement
137
- (the loop's break condition — a failing judge can never spin forever).
110
+ - **Relevance is `ir`'s.** Each round the accumulated hits pass through `ir.select` (default strategy `"conservative"` — distractor-robust); the committed subset becomes `Judgement.relevant`. LLM relevance scoring is known-fragile, so the LLM stays out of it.
111
+ - **Sufficiency is the LLM's.** Informed by ir's model-free `Selection.sufficient` hint, the judge decides whether the committed subset actually satisfies the goal. If not, it emits an improved query — a `refinement` `SubTask` over the same sources. **That refinement is the back-edge.**
112
+
113
+ Both builders accept an injectable double (`formulate=` / `judge=`) for deterministic tests, and both **fail safe**: a formulator error falls back to the raw query (never makes retrieval worse); a judge error returns no refinement (the loop's break condition — a failing judge can never spin forever).
138
114
 
139
115
  ---
140
116
 
141
117
  ## Multi-source search and the fan-in reranker
142
118
 
143
- The agent is **multi-source by default**. The loop stamps each hit's provenance
144
- (`hit.source`), and the default fan-in reranker, `rrf_reranker`, merges
145
- heterogeneous sources **by rank, never by raw score**.
119
+ The agent is **multi-source by default**. The loop stamps each hit's provenance (`hit.source`), and the default fan-in reranker, `rrf_reranker`, merges heterogeneous sources **by rank, never by raw score**.
146
120
 
147
- This matters because scores from different corpora / embedders / retrieval modes
148
- are *incommensurable* — a cosine score (~0–1) and a BM25 score (~0–50) cannot be
149
- compared directly. Reciprocal Rank Fusion (RRF) sidesteps this: within one source
150
- raw scores order and dedup that source's hits (one scale, sound); across sources
151
- only **ranks** interact.
121
+ This matters because scores from different corpora / embedders / retrieval modes are *incommensurable* — a cosine score (~0–1) and a BM25 score (~0–50) cannot be compared directly. Reciprocal Rank Fusion (RRF) sidesteps this: within one source raw scores order and dedup that source's hits (one scale, sound); across sources only **ranks** interact.
152
122
 
153
123
  ```python
154
124
  # Two sources on different score scales:
@@ -158,9 +128,7 @@ only **ranks** interact.
158
128
  agent = raglab.make_search_agent(sources, reranker=raglab.score_reranker)
159
129
  ```
160
130
 
161
- Colliding `artifact_id`s from different sources stay distinct (identity is
162
- `(source, artifact_id)`). Each fused hit keeps its pre-fusion magnitude in
163
- `metadata["source_score"]`. For per-source trust weights or a custom `rrf_k`:
131
+ Colliding `artifact_id`s from different sources stay distinct (identity is `(source, artifact_id)`). Each fused hit keeps its pre-fusion magnitude in `metadata["source_score"]`. For per-source trust weights or a custom `rrf_k`:
164
132
 
165
133
  ```python
166
134
  reranker = raglab.make_rrf_reranker(weights={"skills": 2.0, "web": 0.5}, rrf_k=60)
@@ -192,10 +160,7 @@ def my_formulator(task, source):
192
160
  agent = make_search_agent(sources, planner=my_planner, formulator=my_formulator)
193
161
  ```
194
162
 
195
- A **custom Retriever** is any `callable(query, **params) -> Sequence[ir.SearchHit]`.
196
- It must return `ir.SearchHit` instances (the `Result` alias) — the loop stamps
197
- provenance on its output, so duck-typed hit objects raise at the tagging step.
198
- ir-backed retrievers self-attribute their corpus name.
163
+ A **custom Retriever** is any `callable(query, **params) -> Sequence[ir.SearchHit]`. It must return `ir.SearchHit` instances (the `Result` alias) — the loop stamps provenance on its output, so duck-typed hit objects raise at the tagging step. ir-backed retrievers self-attribute their corpus name.
199
164
 
200
165
  ---
201
166
 
@@ -214,8 +179,7 @@ Everything is exported from the top-level `raglab` namespace.
214
179
  | `Budget` | `max_rounds=3`, `max_sources_per_task=4`, `max_results_per_task=50` |
215
180
  | `Result` | alias for `ir.SearchHit` |
216
181
 
217
- **Role Protocols** (the open-closed strategy seams): `Planner`, `Formulator`,
218
- `Retriever` (re-exported from `ir`), `Evaluator`, `Reranker`, `Citer`.
182
+ **Role Protocols** (the open-closed strategy seams): `Planner`, `Formulator`, `Retriever` (re-exported from `ir`), `Evaluator`, `Reranker`, `Citer`.
219
183
 
220
184
  **Orchestrator & builders:**
221
185
 
@@ -225,69 +189,39 @@ Everything is exported from the top-level `raglab` namespace.
225
189
  | `SingleContextAgent` | The orchestrator dataclass: one ReAct-style loop, sequential sub-tasks. |
226
190
  | <a name="sources"></a>`ir_sources(*names, **search_defaults)` | A `{name: Retriever}` registry backed by named ir corpora. |
227
191
 
228
- **Default roles (the no-LLM thin slice):** `single_subtask_planner`,
229
- `identity_formulator`, `passthrough_evaluator`, `score_reranker`, `rrf_reranker`,
230
- `make_rrf_reranker(*, rrf_k, weights, identity)`, `identity_citer`.
192
+ **Default roles (the no-LLM thin slice):** `single_subtask_planner`, `identity_formulator`, `passthrough_evaluator`, `score_reranker`, `rrf_reranker`, `make_rrf_reranker(*, rrf_k, weights, identity)`, `identity_citer`.
231
193
 
232
- **LLM roles:** `make_llm_formulator(*, formulate=None, params=None, **make_kwargs)`,
233
- `make_llm_evaluator(*, judge=None, select_strategy="conservative", select_kwargs=None, prerank=None, prompt=EVALUATION_PROMPT, ...)`,
234
- and the default `EVALUATION_PROMPT` string.
194
+ **LLM roles:** `make_llm_formulator(*, formulate=None, params=None, **make_kwargs)`, `make_llm_evaluator(*, judge=None, select_strategy="conservative", select_kwargs=None, prerank=None, prompt=EVALUATION_PROMPT, ...)`, and the default `EVALUATION_PROMPT` string.
235
195
 
236
196
  ---
237
197
 
238
198
  ## Architecture & boundaries
239
199
 
240
- `raglab` **owns the agent**: the value types, the role Protocols, the control
241
- loop with the back-edge, the budget governor, the source registry, and the
242
- cross-source fan-in.
200
+ `raglab` **owns the agent**: the value types, the role Protocols, the control loop with the back-edge, the budget governor, the source registry, and the cross-source fan-in.
243
201
 
244
- It **consumes from `ir`** (and does not reimplement): `ir.as_retriever` (corpus →
245
- Retriever), `ir.retrievers()` (the live registry view), `ir.make_llm_formulator`
246
- (the query rewriter), `ir.select` + its `Selection.sufficient` signal (relevance
247
- + the sufficiency hint), and `ir.fuse_hits` (RRF). The `Result` type and the
248
- `Retriever` contract are **ir's** (single source of truth).
202
+ It **consumes from `ir`** (and does not reimplement): `ir.as_retriever` (corpus → Retriever), `ir.retrievers()` (the live registry view), `ir.make_llm_formulator` (the query rewriter), `ir.select` + its `Selection.sufficient` signal (relevance
203
+ + the sufficiency hint), and `ir.fuse_hits` (RRF). The `Result` type and the `Retriever` contract are **ir's** (single source of truth).
249
204
 
250
- **Dependency direction is one-way:** `raglab` imports `ir` (and `oa` for the LLM
251
- roles, lazily); **`ir` never imports `raglab`.** Keeping `oa` opt-in is what lets
252
- `import raglab` stay offline.
205
+ **Dependency direction is one-way:** `raglab` imports `ir` (and `oa` for the LLM roles, lazily); **`ir` never imports `raglab`.** Keeping `oa` opt-in is what lets `import raglab` stay offline.
253
206
 
254
- What lives **elsewhere:** answer synthesis / generation and the
255
- Citer/Verifier (which needs a *generated claim* to verify) belong in the
256
- RAG/generation layer (`srag`), not the search agent. raglab's deliverable is
257
- **pointers + extractions**, not an essay.
207
+ What lives **elsewhere:** answer synthesis / generation and the Citer/Verifier (which needs a *generated claim* to verify) belong in the RAG/generation layer (`srag`), not the search agent. raglab's deliverable is **pointers + extractions**, not an essay.
258
208
 
259
- Where it sits in the ecosystem: **`raglab` → `ir` → {`ef`, `vd`}** — `ir` is the
260
- retrieval substrate, `ef` owns embedders/segmenters, `vd` is the vector-store
261
- facade.
209
+ Where it sits in the ecosystem: **`raglab` → `ir` → {`ef`, `vd`}** — `ir` is the retrieval substrate, `ef` owns embedders/segmenters, `vd` is the vector-store facade.
262
210
 
263
211
  ---
264
212
 
265
213
  ## Status & roadmap
266
214
 
267
- Shipped at **0.2.4**: the `SingleContextAgent` control loop with the back-edge,
268
- all six role Protocols, the no-LLM defaults, the LLM Formulator + Evaluator, and
269
- the RRF cross-source fan-in reranker. The roles, value types, and loop are
270
- stable; richer strategies are added behind the same contracts.
215
+ Shipped at **0.2.4**: the `SingleContextAgent` control loop with the back-edge, all six role Protocols, the no-LLM defaults, the LLM Formulator + Evaluator, and the RRF cross-source fan-in reranker. The roles, value types, and loop are stable; richer strategies are added behind the same contracts.
271
216
 
272
- The living roadmap is **[issue #2](https://github.com/thorwhalen/raglab/issues/2)**
273
- (Composable Search Agent on ir, the *ir_09* reference design). Not yet built:
217
+ The living roadmap is **[issue #2](https://github.com/addaix/raglab/issues/2)** (Composable Search Agent on ir, the *ir_09* reference design). Not yet built:
274
218
 
275
- - **Budget governor refinements** — the per-task results cap currently truncates
276
- in arrival order rather than by rank
277
- ([#5](https://github.com/thorwhalen/raglab/issues/5)); termination as a
278
- separately injected policy is planned.
279
- - **PurposeStore** — persistent, purpose-indexed memory overlay
280
- ([#6](https://github.com/thorwhalen/raglab/issues/6)). There is no cross-run
281
- memory today.
282
- - **`MultiAgentAgent`** — one subagent per sub-task/source (breadth-first, ~15×
283
- cost); promotion swaps only the orchestrator, keeping role contracts identical.
219
+ - **Budget governor refinements** — the per-task results cap currently truncates in arrival order rather than by rank ([#5](https://github.com/addaix/raglab/issues/5)); termination as a separately injected policy is planned.
220
+ - **PurposeStore** — persistent, purpose-indexed memory overlay ([#6](https://github.com/addaix/raglab/issues/6)). There is no cross-run memory today.
221
+ - **`MultiAgentAgent`** — one subagent per sub-task/source (breadth-first, ~15× cost); promotion swaps only the orchestrator, keeping role contracts identical.
284
222
 
285
223
  ---
286
224
 
287
225
  ## House style
288
226
 
289
- Functional over OOP; SOLID when OOP; facades, SSOT, dependency injection;
290
- progressive disclosure; keyword-only args beyond the third positional;
291
- `collections.abc` + frozen `dataclass`es; `Protocol`s for the role seams. Tests
292
- are hermetic (fake retrievers, injected LLM doubles) with a few end-to-end checks
293
- over a real `ir` corpus using the light, numpy-only embedder.
227
+ Functional over OOP; SOLID when OOP; facades, SSOT, dependency injection; progressive disclosure; keyword-only args beyond the third positional; `collections.abc` + frozen `dataclass`es; `Protocol`s for the role seams. Tests are hermetic (fake retrievers, injected LLM doubles) with a few end-to-end checks over a real `ir` corpus using the light, numpy-only embedder.
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "raglab"
9
- version = "0.2.12"
9
+ version = "0.2.13"
10
10
  description = "A medley of tools to make RAG-based applications."
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.10"
@@ -40,11 +40,11 @@ dependencies = [
40
40
  ]
41
41
 
42
42
  [project.urls]
43
- Homepage = "https://thorwhalen.github.io/raglab/"
44
- Repository = "https://github.com/thorwhalen/raglab"
45
- Documentation = "https://thorwhalen.github.io/raglab"
46
- Issues = "https://github.com/thorwhalen/raglab/issues"
47
- Changelog = "https://github.com/thorwhalen/raglab/blob/main/CHANGELOG.md"
43
+ Homepage = "https://addaix.github.io/raglab/"
44
+ Repository = "https://github.com/addaix/raglab"
45
+ Documentation = "https://addaix.github.io/raglab"
46
+ Issues = "https://github.com/addaix/raglab/issues"
47
+ Changelog = "https://github.com/addaix/raglab/blob/main/CHANGELOG.md"
48
48
 
49
49
  [project.optional-dependencies]
50
50
  llm = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes