CLI & debug output¶
varagity.cli.app
¶
CLI argument parsing, subcommand dispatch, and the terminal Q&A loop.
Subcommands: ingest, chat (the default when no subcommand is
given), and eval / eval ocr / eval chat / eval graph.
chat follows the spec §13
startup sequence: ingest the
corpus first, then loop — prompt → retrieve → show matches → grounded
answer — until :quit (or end-of-input, e.g. in a non-interactive
container).
Every subcommand runs through the Prefect flows
(varagity.pipeline), invoked directly in-process — no worker or
deployment (spec §21 #8) — so every ingest stage and every question is a
tracked run at the Prefect UI (:4200).
An ingest refused by the corpus lock — a backup restore holds the corpus
(ADR-019) — is not a crash: ingest and chat say so in one line and
exit 1. They ask the lock before the tracked flow starts, so no failed
flow run's traceback lands above that line.
build_parser()
¶
Build the top-level argument parser.
Returns:
| Type | Description |
|---|---|
ArgumentParser
|
A parser accepting |
ArgumentParser
|
and the registered subcommands; with no subcommand the app runs |
ArgumentParser
|
|
Source code in varagity/cli/app.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
run(argv=None)
¶
Run the varagity command-line interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
list[str] | None
|
Argument vector; defaults to |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The process exit code ( |
Source code in varagity/cli/app.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
varagity.debug.show
¶
Rich-rendered console helpers backing the verbose= parameter convention.
Varagity separates three output channels (spec §14); this module implements the first — human-facing console output — with three levels:
0— off: render nothing.1— low: names and counts.2— high: full metadata, rich panels.
Conventions:
- Every public function in the codebase accepts
verbose: int = settings.DEFAULT_VERBOSEand raises :class:ValueErroron invalid levels (enforced via :func:check_verbose). - All rendering lives here as
v_<function_name>(...)helpers (e.g.v_discover,v_chunk,v_retrieve), keeping presentation out of business logic. Helpers render nothing at level0.
Concrete v_<name> helpers land alongside the features they render.
check_verbose(verbose)
¶
Validate a verbose level.
Called at the top of every function that accepts a verbose parameter,
so an invalid level fails fast instead of silently rendering nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
int
|
Requested verbosity; must be 0 (off), 1 (low), or 2 (high). |
required |
Returns:
| Type | Description |
|---|---|
int
|
The validated level, unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
trace_badges(trace)
¶
Format a retrieval trace as one-line rank badges (spec_v2 §4.6).
The terminal counterpart of the provenance panel's RankBadges:
sem #1 · bm25 #3 · fused 0.94 · rerank +2. An arm that never
surfaced the chunk shows —; the rerank badge appears only when the
rerank stage ran.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
RetrievalTrace
|
The chunk's rank provenance. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The badge string. |
Source code in varagity/debug/show.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
v_chunk(chunks, verbose)
¶
Render chunking results (for a chunking strategy's split).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Sequence[Document]
|
The chunks produced for one document (langchain
|
required |
verbose
|
int
|
0 = nothing; 1 = file → chunk count; 2 = a panel per chunk with its full metadata. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
v_condensed(original, condensed, verbose)
¶
Render the condensed search query (for CondenseContextEngine.prepare).
The terminal counterpart of the evidence panel's "Searched for: …" line (spec_v3 §4.7): whenever retrieval ran on something other than the user's words, the rewrite is shown rather than silently applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original
|
str
|
The user's question, verbatim (shown at level 2). |
required |
condensed
|
str
|
The standalone search query the condenser produced. |
required |
verbose
|
int
|
0 = nothing; 1 = the condensed query; 2 = a panel pairing it with the original wording it replaced. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
v_discover(buckets, verbose)
¶
Render discovery results (for :func:~varagity.ingest.discovery.discover_documents).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buckets
|
Buckets
|
The discovered corpus buckets. |
required |
verbose
|
int
|
0 = nothing; 1 = counts per bucket; 2 = also the file list. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
v_hyde(query, passage, verbose)
¶
Render the hypothetical passage (for HydeRetriever, ADR-016).
The :func:v_condensed counterpart for the HyDE stage: whenever the
dense arm is about to search with generated text rather than the
user's words, the substitution is shown rather than silently applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query the passage was generated for (shown at level 2). |
required |
passage
|
str
|
The hypothetical answer passage steering the dense arm. |
required |
verbose
|
int
|
0 = nothing; 1 = a one-line notice with the passage's head; 2 = a panel pairing the full passage with the query. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
v_retrieve(chunks, verbose)
¶
Render retrieval results (for a retriever's retrieve).
Mirrors the reference's v_retrieve_docs: at level 2 each retrieved
chunk becomes a panel with its score, source, content, (when the chunk
was ingested with CONTEXTUALIZE on) its situating context, and
(when the retriever attached one) its :func:trace_badges rank
provenance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Sequence[RetrievedChunk]
|
The retrieved chunks, best first. |
required |
verbose
|
int
|
0 = nothing; 1 = retrieved count; 2 = a panel per chunk (score/source/content/context/trace). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
v_situate_context(chunk_text, context, verbose)
¶
Render one situating blurb (for :func:~varagity.context.contextual.situate_context).
Level 1 stays quiet — the loader's contextualization sub-progress bar is the per-chunk signal there; level 2 shows each blurb next to a snippet of the chunk it situates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_text
|
str
|
The chunk being situated (snippet shown as the subtitle). |
required |
context
|
str
|
The LLM-generated situating blurb. |
required |
verbose
|
int
|
0/1 = nothing; 2 = a panel per blurb. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in varagity/debug/show.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |