Repository navigation
feat(storage): utopia, push vCons into a bitemporal knowledge graph - #205
Merged
Merged
Conversation
Adds storage.utopia. Each vCon is rendered as dated Markdown sentences and uploaded to a Utopia knowledge base as <uuid>.md, where Utopia extracts facts with world-time and record-time and keeps the quoted evidence. Utopia dates a document only from a leading YYYY-MM-DD line in a Markdown file and reads JSON as flat text, so rendering happens here rather than uploading the raw vCon. - save uploads first, then tombstones the older <uuid>.md, so a failed upload loses nothing. Unchanged content is skipped by Utopia's sha256 dedup, which also makes POST retries safe. - delete tombstones. get is not offered: Utopia holds the rendering. - Logs in with a service account (the REST API takes session JWTs, not personal access tokens) and logs in again on 401. - Every rendering carries a lawful basis sentence, "none recorded" when absent. require_analysis_grant (default off) skips vCons whose basis does not grant analysis. - Reads wtf_transcription, OpenAI, Deepgram and legacy transcript bodies and legacy attachment type fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Utopia extracts chunk by chunk, so the date in a transcript heading never reached facts drawn from later paragraphs, and summary sentences carried no date at all. Facts from them landed with no world time. Each summary and transcript paragraph now opens with "On <date>,", taken from its dialog's start and falling back to the vCon's created_at. Legacy single-string transcripts are split on blank lines so each paragraph gets the prefix. Against a live Utopia with a hosted chat model, facts with a valid_from on the same test vCon went from 1 of 16 to 10 of 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
storage.utopia, a storage module that sends each vCon to a Utopia knowledge base. Utopia extracts facts from documents, dates each fact on a world clock and a record clock, and keeps the quoted evidence, so a conserver feeding it can answer "what was said about X as of date Y" with the source vCon behind each answer.Design
YYYY-MM-DDline in a Markdown file. The module renders the vCon as dated sentences (On 2026-09-18 at 14:02, A and B had a recorded call lasting 240 seconds.) and uploads<uuid>.md.<uuid>.md, so a failed upload loses nothing. Unchanged content is skipped by Utopia's sha256 dedup, which also makes retried POSTs safe; the retry session is the onestorage.vcon_mcpalready uses.Lawful basis
Every rendering ends with a lawful basis sentence, or
Lawful basis: none recorded.Nothing is filled in.require_analysis_grant(default off) skips vCons whose basis does not grantanalysisor has expired.Tests
common/storage/utopia/test_utopia.py, 7 tests: rendering of a legacy0.0.1record and a current one withwtf_transcriptionandlawful_basis, and save, re-save, supersede, delete, 401 re-login and the grant gate against a loopback fake of Utopia's four endpoints.Live run
Run once against a local Utopia (
ghcr.io/deeplethe/utopia:0.1.0-rc6,qwen2.5:7bfor extraction,nomic-embed-textfor embeddings), pushing one synthetic record through the realstorage.utopiacode. All four steps passed:On the 7B model, extraction was thin: five facts from one call, mostly name aliases, none from the party or dialog sentences.
Rerun on a droplet with a hosted chat model over the OpenAI-compatible API, same record, same four steps passing. Extraction then gave 16 facts, including the rendered sentences: each party taking part, their phone and email, who had a conversation with whom, and a callback request from the amended summary. So the rendering works; the thin local result was the model.
That run showed one gap, fixed in
cbc84ad: only 1 of 16 facts carried a world time (valid_from), because Utopia extracts chunk by chunk and summary and transcript paragraphs had no date of their own. Each paragraph now opens withOn <date>,. Against the same Utopia, dated facts went to 10 of 24. The rest are mostly timeless attributes such as names and contact details.Not in this PR
redactedvCon arrives (needs KB Admin and Utopia's purge endpoint).tel/mailtoas Utopia entity aliases.🤖 Generated with Claude Code