Server-Side Tenant Isolation, Versioning, and Memory Rollback
Explore how server-side sessions create secure team and user namespaces for AI agent memory. Learn to prevent cross-tenant vector recall leaks, preserve version history, roll back incorrect facts, expire unverified entries, and test isolation guarantees.
We'll cover the following...
In the last lesson, we built a provenance gate that decides whether a source may write to memory at all. Our memory still has two gaps. It’s one set of files for everyone, and the assistant now serves more than one team. And a write that passes the gate is saved in place, so if a trusted source sends a wrong value, the old value is gone.
In this lesson, we’ll give each team and each engineer their own namespace: a storage location chosen by the server from the login session. We’ll reproduce a cross-team leak in vector recall and close it. Then we’ll keep every version of every fact, let unverified entries expire, and roll a bad fact back to a good version.
Two teams, one memory file
Two teams now share the assistant: checkout and payments. Each team tells the assistant where its escalations go. Both statements are user turns, so the provenance gate would pass both. Let’s send them through reconcile() from lesson 5.5.
In the code above:
Lines 5–6: We write one statement from each team. Both use the same subject, “escalation channel.”
Lines 9–11: We clear memory and reconcile both statements.
Line 12: We print the memory file.
The second team’s statement overwrites the first:
checkout | ADDpayments | UPDATEfacts.json: {'escalation_channel': '#payments-oncall'}
reconcile() did what it was built for. It saw a new value for an existing key and chose UPDATE. The issue is that both teams write to the same file. The next time a checkout engineer asks where to escalate, the assistant names the payments channel.
Give each team a namespace
The fix is to build the storage path from who is asking. Team facts go in a folder for the team, and personal rules, such as an engineer’s preferred answer format, go in a folder for that engineer.
The team and user must come from the server’s login session. If the path used a team name sent in the request, anyone could write to another team’s memory by sending that team’s name. This is the same lesson as the source tag in lesson 7.1: our code sets the fields that decide access, and the request never does.
Let’s build the namespace and a ...