lakeFS
Track exactly which version of a policy document, taxonomy, or reference file an agent read, by capturing the lakeFS commit SHA on every object access.
lakeFS is one bundled versioned-data source — if your data lives elsewhere,
implement the same capture against any version-controlled store through the
generic vcs protocol (pip install briefcase-ai[vcs]).
pip install briefcase-ai[lakefs] For: reproducible RAG & data lineage
Install
pip install briefcase-ai[lakefs]The [lakefs] extra installs the lakefs package. Import from
briefcase.integrations.lakefs.
Track Reads with a Context Manager
Open a versioned_context and every read inside it is tagged with the resolved
commit SHA.
from briefcase.integrations.lakefs import versioned_contextfrom unittest.mock import Mock
class MockBriefcaseClient: def __init__(self): self.config = { "lakefs_endpoint": "https://example.lakefscloud.io/api/v1", "lakefs_access_key": "your_access_key", "lakefs_secret_key": "your_secret_key", }
client = MockBriefcaseClient()
with versioned_context(client, "knowledge-base", "main") as lakefs: refund_policy = lakefs.read_object("docs/refund_policy.pdf") taxonomy = lakefs.read_object("config/category_taxonomy.json")
print(f"Read refund policy: {len(refund_policy)} bytes") print(f"Read taxonomy: {len(taxonomy)} bytes") print(f"Commit SHA: {lakefs.get_commit()}")Track Reads with a Decorator
@versioned injects a VersionedClient as the versioned_client keyword
argument. Pass your Briefcase client as briefcase_client when you call the
function.
from briefcase.integrations.lakefs import versionedfrom unittest.mock import Mock
class MockBriefcaseClient: def __init__(self): self.config = { "lakefs_endpoint": "https://example.lakefscloud.io/api/v1", "lakefs_access_key": "your_access_key", "lakefs_secret_key": "your_secret_key", }
client = MockBriefcaseClient()
@versioned(repository="knowledge-base", branch="main")def classify_ticket(ticket: dict, versioned_client=None) -> dict: policy = versioned_client.read_object("docs/refund_policy.pdf") taxonomy = versioned_client.read_object("config/category_taxonomy.json")
return { "category": "billing", "commit_sha": versioned_client.get_commit(), "bytes_read": len(policy) + len(taxonomy), }
ticket = {"id": "TKT-4471", "subject": "Refund request"}result = classify_ticket(ticket, briefcase_client=client)print(f"Category: {result['category']}")print(f"Commit SHA: {result['commit_sha']}")Use the Client Directly
Construct a VersionedClient when you need explicit control over reads,
existence checks, and listings.
from briefcase.integrations.lakefs import VersionedClientfrom unittest.mock import Mock
class MockBriefcaseClient: def __init__(self): self.config = { "lakefs_endpoint": "https://example.lakefscloud.io/api/v1", "lakefs_access_key": "your_access_key", "lakefs_secret_key": "your_secret_key", }
client = MockBriefcaseClient()
versioned_client = VersionedClient( repository="knowledge-base", branch="main", briefcase_client=client,)
for path in ["docs/refund_policy.pdf", "docs/shipping_policy.pdf"]: if versioned_client.object_exists(path): content = versioned_client.read_object(path) print(f"Read {path}: {len(content)} bytes")
objects = versioned_client.list_objects(prefix="docs/")print(f"Found {len(objects)} objects in docs/")print(f"Commit SHA: {versioned_client.get_commit()}")VersionedClient Methods
| Method | Returns |
|---|---|
read_object(path, return_metadata=False) | Object bytes, optionally with metadata |
upload_object(path, data, content_type=...) | Writes bytes to the branch |
list_objects(prefix="") | Objects under a prefix |
object_exists(path) | True if the object is present |
get_commit() | The resolved commit SHA for this client |
VersionedClient(repository, branch, commit="latest", briefcase_client=None, ...)
resolves commit="latest" against the branch head; pin a SHA to read a fixed
version.
Where this fits
Capturing a lakeFS commit SHA is part of the Store & Query act: pin exactly what your agents read so replays are reproducible.