Versions
Every graph comes with versioning. Each saved change is a numbered version, any version can be asked, and any version can be restored in about a second.
Examples that pass store= use the client-contracts graph made with sc.create_graph in Adding documents. Leave store= out to use your default graph.
Ask the past
now = sc.query("What is the notice period?") # current answer
old = sc.query("What is the notice period?", version=1) # version 1's answer
old.behind # True: you are reading an older version on purposeAn old version answers from its own documents, exactly as it did then. Documents added later never leak into it.
See the timeline
for v in sc.versions(store="client-contracts"):
print(v.number, v.kind, v.created_at)
print(" added:", [d.source_id for d in v.changes.added])
print(" removed:", v.changes.removed)Undo
sc.versions.restore(1, store="client-contracts")
Restore makes a new version whose documents match version 1 and points the graph at it. Nothing is rewritten and nothing is lost; the versions in between stay in history and stay askable. There is no re-indexing, so it finishes in about a second.
Drafts
A draft is an unpublished line of your graph. Add documents to it and ask it questions without changing what your users see, then publish when you are ready.
sc.drafts.open("policy-update", store="client-contracts")
sc.ingest([...], store="client-contracts", draft="policy-update")
sc.query("...", store="client-contracts", draft="policy-update")
sc.drafts.publish("policy-update", store="client-contracts")