import tempfile
import uuid
import jammi
from jammi.errors import AlreadyExists, FailedPrecondition, InvalidArgument, NotFound
from jammi.testing import LiveServer
from jammi_cookbook.claims import claim
CONDITIONS = (InvalidArgument, NotFound, AlreadyExists, FailedPrecondition)24 The error taxonomy — each failure names its cause
Verbs: register_channel · add_channel_columns · list_channels · search · lexical_search · describe_table · jammi.errors · Background: a typed error vocabulary — a failure with a known cause names it, as a gRPC status code on the wire (The gRPC Authors 2024) and as a Python class in the client, so a caller branches on the cause instead of parsing a message · Checked: parity (each failure raises the same class in process and from a server, and the server’s status code names the same condition).
The evaluation-channels chapter measures the evidence-channel registry’s happy path. This chapter measures its failures — and, through them, the error vocabulary every engine verb shares. A failure with a known cause is never a generic fault. It raises a jammi.errors class that names the condition, and over the wire it carries the gRPC status code for that condition:
| condition | class | status code |
|---|---|---|
| the argument is malformed | InvalidArgument |
INVALID_ARGUMENT |
| the thing named does not exist | NotFound |
NOT_FOUND |
| the thing being created exists already | AlreadyExists |
ALREADY_EXISTS |
| the state the operation needs does not hold | FailedPrecondition |
FAILED_PRECONDITION |
A more specific refusal refines one of these — ModelNotFound and NoReadyIndex are NotFounds, ModelReferenced a FailedPrecondition — so a caller catches as narrowly as it needs to. Everything else is a BackendError, the class all four refine: the residual for a fault with no named cause.
24.1 Four failures, written once
Each failure is a real misuse of the registry: registering a channel id twice, extending a channel never registered, redeclaring a column with another type, and registering an empty channel id.
def failure(action) -> tuple[str, str | None]:
"""The class an action raises, and the status code when it came over the wire."""
try:
action()
except CONDITIONS as raised:
code = getattr(raised, "code", None)
return type(raised).__name__, code.name if code is not None else None
raise AssertionError("the action was expected to fail")
def failures(db) -> dict:
with db.tenant_scope(str(uuid.uuid4())):
db.register_channel("scored_by", priority=50, columns=[("score", "Float64")])
return {
"register twice": failure(lambda: db.register_channel(
"scored_by", priority=50, columns=[("score", "Float64")])),
"extend an unregistered channel": failure(lambda: db.add_channel_columns(
"never_registered", columns=[("note", "Utf8")])),
"redeclare a column's type": failure(lambda: db.add_channel_columns(
"scored_by", columns=[("score", "Utf8")])),
"an empty channel id": failure(lambda: db.register_channel(
"", priority=1, columns=[("x", "Utf8")])),
}24.2 In process, then against a server
with jammi.connect(f"file://{tempfile.mkdtemp()}") as db:
local = failures(db)
with LiveServer(tempfile.mkdtemp()) as server, jammi.connect(server.endpoint) as db:
served = failures(db)
print(f"{'failure':<32}{'class (in process)':<22}{'class (server)':<22}{'status code'}")
for name in local:
print(f"{name:<32}{local[name][0]:<22}{served[name][0]:<22}{served[name][1]}")failure class (in process) class (server) status code
register twice AlreadyExists AlreadyExists ALREADY_EXISTS
extend an unregistered channel NotFound NotFound NOT_FOUND
redeclare a column's type FailedPrecondition FailedPrecondition FAILED_PRECONDITION
an empty channel id InvalidArgument InvalidArgument INVALID_ARGUMENT
expected = {
"register twice": ("AlreadyExists", "ALREADY_EXISTS"),
"extend an unregistered channel": ("NotFound", "NOT_FOUND"),
"redeclare a column's type": ("FailedPrecondition", "FAILED_PRECONDITION"),
"an empty channel id": ("InvalidArgument", "INVALID_ARGUMENT"),
}
for name, (cls, code) in expected.items():
claim(f"{name} raises {cls} on both transports, and {code} on the wire",
local[name][0] == cls and served[name] == (cls, code))✓ register twice raises AlreadyExists on both transports, and ALREADY_EXISTS on the wire
✓ extend an unregistered channel raises NotFound on both transports, and NOT_FOUND on the wire
✓ redeclare a column's type raises FailedPrecondition on both transports, and FAILED_PRECONDITION on the wire
✓ an empty channel id raises InvalidArgument on both transports, and INVALID_ARGUMENT on the wire
Every failure raises the same class on both transports, and the server’s status code names the same condition. A program that catches AlreadyExists to treat a repeated registration as done, or NotFound to register a channel on first use, works unchanged in process and against a server — and neither ever reads a message.
24.3 Searching before there is anything to search
A missing thing is a NotFound whether the caller named it or the verb went looking for it. A search or lexical_search that names no table resolves the source’s newest ready index; before one is built, that is NoReadyIndex, a NotFound whose message names the verb that builds the index. A table named but never built is a plain NotFound.
from jammi.errors import NoReadyIndex
from jammi_cookbook import fixtures
def missing(db) -> dict:
with db.tenant_scope(str(uuid.uuid4())):
db.add_source("corpus", url=fixtures.url("tiny_corpus.parquet"), format="parquet")
found = {}
for name, action in {
"search before any embedding table": lambda: db.search(
"corpus", query=[0.0] * 8, k=3),
"lexical_search before any index": lambda: db.lexical_search(
"corpus", text="protein folding", k=3),
"describe a table never built": lambda: db.describe_table("corpus_never_built"),
}.items():
try:
action()
except NotFound as raised:
code = getattr(raised, "code", None)
found[name] = (type(raised).__name__, code.name if code else None, str(raised))
return found
with jammi.connect(f"file://{tempfile.mkdtemp()}") as db:
local_missing = missing(db)
with LiveServer(tempfile.mkdtemp()) as server, jammi.connect(server.endpoint) as db:
served_missing = missing(db)
for name, (cls, code, message) in served_missing.items():
print(f"{name:<36}{local_missing[name][0]:<14}{cls:<14}{code}")
print(f" {message}")search before any embedding table NoReadyIndex NoReadyIndex NOT_FOUND
source `corpus` has no ready embedding table; `generate_embeddings` builds one
lexical_search before any index NoReadyIndex NoReadyIndex NOT_FOUND
source `corpus` has no ready lexical index; `build_lexical_index` builds one
describe a table never built NotFound NotFound NOT_FOUND
result table `corpus_never_built` not found
claim("each missing-artifact failure is measured on both transports",
local_missing.keys() == served_missing.keys() == {
"search before any embedding table",
"lexical_search before any index",
"describe a table never built",
})
claim("each raises the same class with the same message in process and from a server, as NOT_FOUND",
all(local_missing[name][0] == cls and code == "NOT_FOUND" and local_missing[name][2] == message
for name, (cls, code, message) in served_missing.items()))
claim("a search with nothing to search is NoReadyIndex, naming the verb that builds it",
served_missing["search before any embedding table"][0] == "NoReadyIndex"
and "generate_embeddings" in served_missing["search before any embedding table"][2]
and served_missing["lexical_search before any index"][0] == "NoReadyIndex"
and "build_lexical_index" in served_missing["lexical_search before any index"][2])
claim("and a table never built is NotFound",
served_missing["describe a table never built"][0] == "NotFound")✓ each missing-artifact failure is measured on both transports
✓ each raises the same class with the same message in process and from a server, as NOT_FOUND
✓ a search with nothing to search is NoReadyIndex, naming the verb that builds it
✓ and a table never built is NotFound
24.4 Bridge note
A cause is a type, not a sentence. The engine names each failure it can explain — malformed, missing, already there, not in the required state — with a gRPC status code on the wire (The gRPC Authors 2024) and the matching
jammi.errorsclass in the client, refined by resource where a caller needs more (ModelReferenced,NoReadyIndex). The classes are the same on both transports because both derive them from the one classification the server sends.