DEV Community

Shivam Dwivedi
Shivam Dwivedi

Posted on Fully Autonomous

Build the public graph from allowed fields

An export can delete every secret field its author remembered and still leak the next field somebody adds.

SessionGraph’s public-graph code takes a different route. It constructs a new object from allowed fields and validates the resulting shape. [1] That is a useful pattern even if you never use its session viewer.

I made a small synthetic example of the difference. No real conversation history is involved.

The field that arrived after the filter

The local object below has a title, messages and a newly added debug note. Deleting the title and messages leaves the debug note behind. Constructing the public object never copies it in the first place.

import json
session = {"id": "local-A", "group": 0, "parent": None,
           "title": "synthetic private title", "messages": ["private text"],
           "new_debug_note": "synthetic confidential note"}
redacted = {k: v for k, v in session.items() if k not in {"title", "messages"}}
public = {"id": 0, "group": session["group"], "parent": None}
def validate(value):
    if set(value) != {"id", "group", "parent"}:
        raise ValueError("unexpected fields")
    for key in ("id", "group"):
        if type(value[key]) is not int or value[key] < 0:
            raise ValueError("invalid number")
    if value["parent"] is not None:
        raise ValueError("this one-node example has no parent")
validate(public)
assert "new_debug_note" in redacted
rejected = 0
for bad in (redacted, {**public, "new_debug_note": "leak"},
            {**public, "id": True}, {**public, "group": -1}):
    try:
        validate(bad)
    except ValueError:
        rejected += 1
assert rejected == 4
print("deletion kept new field:", "new_debug_note" in redacted)
print("constructed:", json.dumps(public, sort_keys=True))
print("invalid payloads rejected:", rejected)
Enter fullscreen mode Exit fullscreen mode

Save it as demo.py and run python3 demo.py:

deletion kept new field: True
constructed: {"group": 0, "id": 0, "parent": null}
invalid payloads rejected: 4
Enter fullscreen mode Exit fullscreen mode

The validator is intentionally tiny: one root node, a numeric group, and no parent. It also rejects a boolean ID. Python’s bool is a subclass of int, so isinstance(True, int) would accept a value this little wire format excludes. The exact-type check makes that choice explicit.

Deleting title and messages leaves a newly added debug note in a synthetic export. Constructing only id, group and parent excludes the note; exact-shape validation rejects unexpected fields.

Original diagram of the executed synthetic payload check. This is an explanatory fixture, not a screenshot or security audit of SessionGraph. Image by Shivam Dwivedi.

Read the product’s actual boundary

In the checked SessionGraph revision, exported sessions always carry graph-specific IDs, groups and parent/fork links. Settings control optional statistics and recognized model or harness names. The validator derives the expected key set from those settings and rejects extra keys. [1]

Its privacy document distinguishes local import from optional publishing. It says selected public snapshots exclude conversation text, code, paths and native IDs; it also warns that timestamps and activity can reveal work patterns. [2] Removing prose does not make a graph unrelated to its owner.

The documentation also says Claude Code discovery searches accessible folders across the computer by default, while a saved custom source path or CLAUDE_CONFIG_DIR restricts that discovery. [2] That is a separate boundary from what a public export includes. I have not launched the application, imported histories, changed source locations or published a graph.

Keep construction and validation together

For a real export, I would give the producer an explicit public type and have the receiver enforce that same shape. Construction prevents accidental copying; validation catches an unexpected payload that still reaches the boundary. The example checks those two jobs separately.

It is not a general personal-data filter. Free text placed inside an allowed field could still disclose something, and a valid relationship graph can reveal relationships. The SessionGraph format goes further than this toy validator with field-specific checks, ancestry checks and size limits. [1] Those require their own tests rather than a promise that “allowlisted” means harmless.

The practical payoff is maintenance: adding a private field should not silently add a public field. Make that transition require a deliberate schema change.

References

  1. Alex Vilchis and SessionGraph contributors, public-graph construction and validation.

  2. SessionGraph contributors, privacy and local data.

  3. SessionGraph, project overview.

Asset credits

Original explanatory figure and example, CC BY 4.0. Credit: Shivam Dwivedi. No third-party image assets.

AI disclosure

AI was used to draft the article.

Top comments (0)