SourceStore
The port that keeps a document's source as it was asked, so it can be read again.
Port: SourceStore, declared in
indx_interfaces.protocols
over StoredSource in
indx_interfaces.store
(ADR-0081).
A StoredSource is a digest, the Source a request named, and an optional expiry. An
inline source carries its bytes as base64. A URI source is the URI with its checksum set
to the digest. Reading a document again is an ordinary request built from the stored
value.
class SourceStore(Protocol): def put(self, owner: OwnerId, source: StoredSource) -> None: ... def get(self, owner: OwnerId, digest: SourceDigest) -> StoredSource | None: ... def list(self, owner: OwnerId) -> tuple[SourceDigest, ...]: ... def delete(self, owner: OwnerId, digest: SourceDigest) -> bool: ... def purge(self, now: datetime) -> int: ...A port of its own rather than a field on StoredDocument, because every Use screen
reads that record and none wants the bytes back. Two owners use it. A visitor’s source
expires with the kept document. The installation’s copy, taken when a document joins a
dataset, has no expiry and goes when no dataset
holds the digest. Three backends ship: memory, sqlite and postgres, named by
INDX_SOURCE_STORE. Unset, nothing is retained.
Contract
Section titled “Contract”- Owner. Every method but
purgetakes anOwnerIdfirst, and nothing crosses owners. - Identity. Within an owner, a source is its digest;
putreplaces the one with the same digest. - Expiry.
getandlistnever return a source past itsexpires_at. One with noexpires_atnever expires, andpurgeleaves it. - Idempotence.
deleteof a digest that is not there isFalse. - Order.
listreturns the owner’s digests in order, without loading a source.
tests/unit/test_store_conformance.py
holds every installed backend to these rules.