Artifact and Serialization API Reference
ArtifactIdentity
async_batch_llm.ArtifactIdentity
dataclass
ArtifactIdentity(provider: str | None = None, model: str | None = None, prompt_version: str | None = None, parser_version: str | None = None, application_version: str | None = None, extra: Mapping[str, JSONValue] = dict())
Caller-supplied provenance used to decide whether replay is compatible.
ResumePolicy
async_batch_llm.ResumePolicy
Bases: str, Enum
Which compatible terminal artifact records may bypass provider work.
ArtifactStore
async_batch_llm.ArtifactStore
Bases: Protocol
Provider-neutral asynchronous checkpoint/replay store.
append
async
append(work_item: LLMWorkItem[Any, Any, Any], prepared_item: Any, result: WorkItemResult[Any, Any]) -> None
Durably append one newly executed terminal result.
close
async
iter_results
lookup
async
lookup(work_item: LLMWorkItem[Any, Any, Any], prepared_item: Any, policy: ResumePolicy) -> WorkItemResult[Any, Any] | None
Return the newest compatible reusable result, if any.
prepare_item
async
JsonlArtifactStore
async_batch_llm.JsonlArtifactStore
JsonlArtifactStore(path: str | Path, *, identity: ArtifactIdentity | None = None, user_metadata: Mapping[str, JSONValue] | None = None, include_output: bool = True, include_metadata: bool = True, include_prompt: bool = False, include_context: bool = False, context_in_identity: bool = True, encoder: ValueEncoder | None = None, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None, context_fingerprinter: ContextFingerprinter | None = None, cost_calculator: CostCalculator | None = None, fsync: bool = False)
Append-only version-1 JSONL artifact store.
Prompt and context text are excluded by default; their SHA-256 hashes are
always recorded for compatibility. Output and metadata are included by
default because successful replay requires output. Set include_output
false for audit-only artifacts; those successful records are not replayable.
Source code in src/async_batch_llm/artifacts.py
iter_results
async
Stream a finite, bounded-memory snapshot of complete item records.
Source code in src/async_batch_llm/artifacts.py
prepare_item
async
Create/validate the artifact and fingerprint input before provider work.
Source code in src/async_batch_llm/artifacts.py
read_results
classmethod
read_results(path: str | Path, *, successes_only: bool = False, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None) -> BatchResult[Any, Any]
Read stored results without opening a writer or calling a provider.
Source code in src/async_batch_llm/artifacts.py
SqliteArtifactStore
Indexed SQLite backend for large restartable runs (v0.21). Note that
SqliteArtifactStore.read_results() is an async classmethod, unlike the
synchronous JSONL convenience. It materializes a finite high-water snapshot
through an operationally read-only path connection. Normal reads participate
in SQLite locking and may create empty WAL/SHM coordination sidecars so a
writer can safely start during inspection; live store.iter_results() instead
flushes and inspects that writable store.
async_batch_llm.SqliteArtifactStore
SqliteArtifactStore(path: str | Path, *, identity: ArtifactIdentity | None = None, user_metadata: Mapping[str, JSONValue] | None = None, include_output: bool = True, include_metadata: bool = True, include_prompt: bool = False, include_context: bool = False, context_in_identity: bool = True, encoder: ValueEncoder | None = None, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None, context_fingerprinter: ContextFingerprinter | None = None, cost_calculator: CostCalculator | None = None, durability: SqliteDurability = SqliteDurability.BALANCED, commit_batch_size: int = 100, commit_interval_seconds: float = 0.01, busy_timeout_seconds: float = 5.0, read_batch_size: int = 1000)
Indexed, batched artifact store backed by standard-library SQLite.
One writable instance owns one connection, one executor thread, and one async writer task. It supports sequential reopen but is not a distributed work-claiming or exactly-once execution system.
Source code in src/async_batch_llm/sqlite_artifacts.py
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 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 217 218 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 249 250 251 252 253 | |
close
async
Drain writes, checkpoint/truncate WAL, and terminate the executor.
Source code in src/async_batch_llm/sqlite_artifacts.py
iter_results
Return a bounded keyset iterator over a finite committed snapshot.
Source code in src/async_batch_llm/sqlite_artifacts.py
lookup
async
lookup(work_item: LLMWorkItem[Any, Any, Any], prepared_item: Any, policy: ResumePolicy) -> WorkItemResult[Any, Any] | None
Look up the newest compatible terminal row through a replay index.
Source code in src/async_batch_llm/sqlite_artifacts.py
prepare_item
async
Open/validate the database and fingerprint input before provider work.
Source code in src/async_batch_llm/sqlite_artifacts.py
read_results
async
classmethod
read_results(path: str | Path, *, successes_only: bool = False, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None, read_batch_size: int = 1000) -> BatchResult[Any, Any]
Materialize a finite snapshot through an operationally read-only connection.
Source code in src/async_batch_llm/sqlite_artifacts.py
SqliteDurability
async_batch_llm.SqliteDurability
Bases: str, Enum
SQLite synchronization policy for committed artifact batches.
ResultSerializationError
async_batch_llm.ResultSerializationError
Bases: ValueError, AsyncBatchLLMError
A result value or serialized payload is not safely supported.
Artifact errors
async_batch_llm.ArtifactError
Bases: RuntimeError, AsyncBatchLLMError
Base class for artifact preparation, format, and persistence failures.
async_batch_llm.ArtifactIdentityError
Bases: ArtifactError
One item's strategy cannot satisfy the store's identity contract.
async_batch_llm.ArtifactSerializationError
Bases: ArtifactError
An artifact identity/input/result could not be canonically serialized.
async_batch_llm.ArtifactIOError
Bases: ArtifactError
An artifact could not be read, written, flushed, or closed.
async_batch_llm.ArtifactFormatError
Bases: ArtifactError
An artifact is malformed or uses an unsupported schema version.