When your data is a child's behavioral history, "the retrieval filter had a bug" is not an acceptable failure mode.
For a multi-patient AI system, a strong pattern is to give every child a dedicated memory bank instead of one shared index with metadata filters. Here is why, and what to tighten for production.
Hard partitioning vs. filters
With a shared index, isolation depends on every query remembering to apply the right filter. With one bank per child, a query physically can't reach another child's records.
Use opaque IDs
Readable bank names like child_liam are fine in a demo. In production, use an opaque identifier so names never appear in URLs or logs:
import uuid
bank_id = f"child_{uuid.uuid4().hex}"
Enforce access at the API layer
Isolation of storage doesn't replace authorization. Check that the caller is allowed to see this child before any recall:
from fastapi import Depends, HTTPException
def authorize(child_id: str, user=Depends(get_current_user)):
if child_id not in user.allowed_children:
raise HTTPException(status_code=403, detail="Not permitted")
return child_id
Add role-scoped access (a parent and a therapist don't need identical views) and an audit log of who recalled what, and when.
Top comments (0)