39Staleness and recompute — sensing a derived table’s drift, and repairing it
Verbs:generate_embeddings → build_neighbor_graph → propagate_embeddings under cache="use" · describe_table · staleness · derives_from · refresh_embeddings · recompute(table, cascade=…) · verify_materialization · list_jobs / job · Background: a materialized artifact is the output of a recorded definition over a recorded input state(Kleppmann 2017); it is fresh while both still hold, and a change to either is detectable · Checked: measurement (every outcome observed live on the papers).
A derived table is only as current as what it was built from. When the source under an embedding table changes, the neighbour graph built on those embeddings, and the propagation built on that graph, are silently out of date — unless the engine can say so. It can, because every result table records how it was produced: its definition (a hash of the producing parameters, the model and the environment) and an anchor for each input (a result table’s content digest, or a source’s read instant). This chapter builds a three-step chain over the papers, then walks through what the engine senses and how it repairs:
Reuse — a producer asked for an exact derivation it already has returns it.
A changed definition — asked about a different definition, a table is stale.
A changed input — the source changes, the embeddings refresh, and everything derived from them senses the drift and is recomputed, once, on request.
import tempfilefrom pathlib import Pathimport jammiimport pyarrow as paimport pyarrow.parquet as pqfrom jammi_cookbook import datasets, encoders, scalefrom jammi_cookbook.claims import claimSCALE = scale.current()MODEL = encoders.text(SCALE)work = Path(tempfile.mkdtemp())db = jammi.connect(f"file://{tempfile.mkdtemp()}")# The papers, as a source this chapter owns — its file is what changes below.arxiv = datasets.arxiv(db, SCALE)papers = db.sql(f"SELECT paper_id, title, abstract FROM {arxiv.papers}.public.{arxiv.papers}")pq.write_table(papers, work /"papers.parquet")db.add_source("papers", url=str(work /"papers.parquet"), format="parquet")embeddings = db.generate_embeddings(source="papers", model=MODEL, columns=["title", "abstract"], key="paper_id")graph = db.build_neighbor_graph("papers", k=10, embedding_table=embeddings, cache="use")propagated = db.propagate_embeddings("papers", embedding_table=embeddings, edge_graph_table=graph, hops=2, alpha=0.1, output="final", cache="use")print(f"embeddings → {graph[:40]}… → {propagated[:40]}…")
2026-10-03T07:47:51.544236Z WARN jammi_kernels::admission: fused-kernel domain check failed; falling back to the eager composition op="attention_block_fused" predicate="head_dim_is_attention_block_fixed_head_dim"
39.1 Reuse — an exact derivation is returned, not recomputed
With cache="use", a producer first looks for a table it already made from the same definition over the same inputs, and returns it. Table names make this visible: a reuse returns the same name, a computation a new one.
outcomes = {"the same neighbour graph": db.build_neighbor_graph("papers", k=10, embedding_table=embeddings, cache="use") == graph,"a graph with k = 5": db.build_neighbor_graph("papers", k=5, embedding_table=embeddings, cache="use") == graph,"the same propagation": db.propagate_embeddings("papers", embedding_table=embeddings, edge_graph_table=graph, hops=2, alpha=0.1, output="final", cache="use") == propagated,"the same embeddings": db.generate_embeddings( source="papers", model=MODEL, columns=["title", "abstract"], key="paper_id", cache="use") == embeddings,}for what, reused in outcomes.items():print(f" {what:<26} reused: {reused}")
the same neighbour graph reused: True
a graph with k = 5 reused: False
the same propagation reused: True
the same embeddings reused: False
claim("an identical request over result tables is reused, and a changed parameter computes anew", outcomes["the same neighbour graph"] and outcomes["the same propagation"]andnot outcomes["a graph with k = 5"])claim("embeddings over a file source are never reused: a file has no version to pin",not outcomes["the same embeddings"])
✓ an identical request over result tables is reused, and a changed parameter computes anew
✓ embeddings over a file source are never reused: a file has no version to pin
Each request names the embedding table it reads: the propagation above published a second embedding table on the same source, and a request that named none would read the newest. The graph and the propagation read only result tables, whose content digests pin their inputs exactly, so an identical request is safely reused and a changed parameter (k) computes anew. The embeddings are different: they read a file source, which has no version the engine can pin — a file can change in place — so their reuse can never be proven safe, and they are always recomputed.
39.2 A changed definition
staleness(table, definition) compares a table’s recorded definition, and each recorded input anchor, with the present. Asked about its own recorded definition, the propagation is fresh; asked about another — the definition a changed model, parameter or environment would produce — it is stale, and says why.
recorded = db.describe_table(propagated)["definition_hash"]fresh = db.staleness(propagated, recorded)changed = db.staleness(propagated, "0"*len(recorded))print(f"against its recorded definition: {fresh['staleness']}")print(f"against another definition: {changed['staleness']} "f"— {[r['reason'] for r in changed['reasons']]}")
against its recorded definition: fresh
against another definition: stale — ['definition_changed']
claim("a table is fresh against its own definition", fresh["staleness"] =="fresh")claim("and stale against a changed one, which it names", changed["staleness"] =="stale"and [r["reason"] for r in changed["reasons"]] == ["definition_changed"])
✓ a table is fresh against its own definition
✓ and stale against a changed one, which it names
39.3 A changed input — sense the drift, then recompute
Now the source changes: one paper’s abstract is corrected. refresh_embeddings re-embeds only the rows whose content changed and publishes a new version of the embedding table, so its content digest moves. The graph was built over the old digest, and the engine senses it.
changed_papers = papers.to_pylist()changed_papers[0]["abstract"] = changed_papers[0]["abstract"] +" (corrected)"pq.write_table(pa.Table.from_pylist(changed_papers, schema=papers.schema), work /"papers.parquet")report = db.refresh_embeddings(embeddings)print(f"refresh: {report['outcome']} — {report['inferred_rows']} row(s) re-embedded")graph_definition = db.describe_table(graph)["definition_hash"]drift = db.staleness(graph, graph_definition)print(f"the graph, against its own definition: {drift['staleness']} "f"— {[r['reason'] for r in drift['reasons']]}")print(f"derived from the embeddings: "f"{sorted(e['derived'][:40] for e in db.derives_from(embeddings))}")
refresh: published — 1 row(s) re-embedded
the graph, against its own definition: stale — ['input_advanced']
derived from the embeddings: ['papers__model__20261003T074751767313239_', 'papers__neighbor_graph__20261003T0747517', 'papers__neighbor_graph__20261003T0747517']
claim("the refresh re-embeds only the changed row", report["outcome"] =="published"and report["inferred_rows"] ==1)claim("and the graph built on the old version senses its input advanced", drift["staleness"] =="stale"and [r["reason"] for r in drift["reasons"]] == ["input_advanced"])
✓ the refresh re-embeds only the changed row
✓ and the graph built on the old version senses its input advanced
derives_from names what is built on a table, one hop at a time. The repair is one explicit call: recompute(graph, cascade="downstream") re-runs the graph’s recorded definition over the embeddings’ current version, then sweeps what was built on the graph — the propagation — once.
claim("one recompute repairs the graph and sweeps the propagation built on it",len(repair["recomputed"]) ==2andall(step["outcome"]["outcome"] =="computed"for step in repair["recomputed"]))claim("and the repaired graph is fresh", db.staleness(new_graph, db.describe_table(new_graph)["definition_hash"])["staleness"] =="fresh")
✓ one recompute repairs the graph and sweeps the propagation built on it
✓ and the repaired graph is fresh
A recompute over inputs that have not moved produces the same artifact, and verify_materialization attests it against the original definition:
again = db.recompute(new_graph, cascade="report_only")["recomputed"][0]["recomputed"]print(f"recompute over unmoved inputs: "f"{db.verify_materialization(again, expected_definition=db.describe_table(new_graph)['definition_hash'])['verdict']}")
recompute over unmoved inputs: match
claim("a recompute over unmoved inputs reproduces the artifact its definition names", db.verify_materialization( again, expected_definition=db.describe_table(new_graph)["definition_hash"])["verdict"]=="match")
✓ a recompute over unmoved inputs reproduces the artifact its definition names
39.4 The job queue underneath
Every producer above ran as a job: the same durable queue a fine-tune goes through, recorded and claimed in the caller’s own process for a synchronous call. list_jobs reads them back, and job(id) reattaches to one.
jobs = db.list_jobs()kinds =sorted({j["kind"] for j in jobs})print(f"{len(jobs)} jobs of kinds {kinds}")latest = db.job(jobs[0]["job_id"])print(f"job {jobs[0]['job_id'][:8]}…: {latest.status()}")db.close()
10 jobs of kinds ['embedding', 'neighbor_graph', 'propagate']
job 2d3cc812…: completed
claim("every producer above ran as a job on the one queue", {"embedding", "neighbor_graph", "propagate"} <=set(kinds))
✓ every producer above ran as a job on the one queue
39.5 The boundary — mechanism, not the loop
The engine ships the bounded mechanism: one cache probe per producer call, one staleness read per question, one recompute on one explicit request, one bounded downstream sweep on cascade="downstream". It ships no scheduler and no monitor that triggers a recompute on its own: wiring the sensor (staleness) to the actuator (recompute) on a schedule is the consumer’s composition. One bounded sweep on one explicit request is engine; re-running it on a schedule is a platform built on it.
Kleppmann, Martin. 2017. Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems. O’Reilly Media.