enhancement
major
minor
defect
critical
major
minor
major
#30144
Chat sessions are invisible to their owner in an application with model-based security
Problem
tl-ai-core defines no access rules for tl.ai.execution:AgentSession. No role is granted an operation on the type, and no role rule derives one, not even for the session's owner. The coverage check reports this at startup:
tl.ai.execution:AgentSession: The type "tl.ai.execution:AgentSession" has neither a role rule nor a role parent rule, and no composition holds its objects. ... tl.ai.execution:AgentSession: No role is granted an operation on the type "tl.ai.execution:AgentSession" or on one of its attributes. Its objects are inaccessible to every user.
In an application with model-based security, TL-Script hides every object the acting user may not see. So for a non-administrator, every session, including the user's own, is invisible to:
- referers;
- all(`tl.ai.execution:AgentSession)`, whose size is 0;
- a script function's result: chatStart(...) creates the session but returns null to the calling view command.
The pattern documented on ChatConversationElement.Config#getSubject therefore yields nothing:
$x.referers(`tl.ai.execution:AgentSession#subject`).filter(s -> $s.get(`tl.ai.execution:AgentSession#owner`) == currentUser())
The <chat-conversation input=...> is never bound to the session about its subject. After a tab switch or a reload, the chat shows an empty new chat, although the session exists; the Java route /chat/sessions lists it. After chatStart, the run's answer streams into an unbound pane, and the user's first message is not shown. A message typed there starts a second session about the same subject.
Without security, the same expression finds the session, as a unit test confirms. ChatConversationControl / SessionSelection and the client (followSelection in chat-conversation.tsx) follow a written channel correctly.
Found in the control application tl-factory (Gitea issue TopLogic/tl-factory#16).
Fix
Ship an owner access policy for the chat sessions in tl-ai-core, following the pattern of tl-ai-core.binarySecurity.config.xml (role AiBinaryOwner):
- a technical owner role, created by InitialRolesManager and described in the bundle;
- a reference role rule on tl.ai.execution:AgentSession over its owner;
- grants for that role on the type: Read, and Write so the owner can rename and delete a session;
- the other tl.ai.execution types either get the session as their access parent or are declared internal.
Administrators and system contexts bypass the check as before.
Test
With model-based security on and a non-administrator as the acting user:
- referers on a subject finds the owner's own session and not another user's;
- chatStart called from a secured view script returns the session it created.