Repository navigation
feat(platform): let agent read tools name tasks, projects and conversations - #2984
Merged
Merged
Conversation
…ations The workspace read gate knows four subjects: documents, contacts, products, websites. Tasks, projects and conversations have no way to be named, so a read tool over them cannot be authorized at all — `authorizeRls` denies by default and `tasks` has no row in the matrix to deny from. Add the three subjects, and give `tasks` a `platformPermissions` row that mirrors `projects` exactly. A task has no ACL of its own — `tasks/access.ts` delegates every check to its parent project — so it must never be reachable at a role that could not open the project holding it. Two lists that could silently disagree are now pinned: - `AGENT_READ_SUBJECTS` is a runtime array and `AgentReadSubject` derives from it, so the "a member reads every subject" test iterates the real list instead of a copy. Dropping a grant now fails that test. - Convex needs literal validators, so the wire union is still spelled by hand. A test asserts it matches the array — a subject in one and not the other is an argument-validation error at dispatch, invisible to the type checker. `resolveSessionActionContext` answers a DIFFERENT question — "may this run act here, given its automation's project binding" — over a strict subset. That set is now named `SessionActionSubject` rather than borrowing the read-gate type, which is what surfaced the mismatch: `TOOL_READ_SUBJECT` was typed as the wider union while every value it holds is a session-action subject. Widening the role gate does not by itself make these readable. `documents` and `tasks` still narrow to the caller's team and project visibility, and `conversations` narrows further to its assignment scope. The subject type records that so the next caller does not read `allowed: true` as "the whole org".
7 tasks
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.
Why
The workspace read gate (
resolveWorkspaceReadAccess) knows exactly four subjects:documents,contacts,products,websites. Tasks, projects and conversations cannot be named to it, so a read tool over any of them cannot be authorized at all — andtaskshas no row inplatformPermissionseither, soauthorizeRlswould deny it by default even if it could be named.Groundwork for giving the chat assistant reach into the organization's work. No behaviour changes here: nothing calls the new subjects yet.
What changed
Three subjects added, and a
platformPermissionsrow fortasksthat mirrorsprojectson every role. A task has no ACL of its own —tasks/access.tsdelegates every check to its parent project — so it must never be reachable at a role that could not open the project holding it.projects,conversationsandconversationMessagesalready had rows.Two lists that could silently disagree are now pinned.
AGENT_READ_SUBJECTSis a runtime array andAgentReadSubjectderives from it, so the existing "an active member reads every workspace subject" test iterates the real list rather than its own copy of it.SessionActionSubjectis now its own name.resolveSessionActionContextanswers a different question — may this run act here, given its automation's project binding — over a strict subset that excludesprojectsandconversations. It had been borrowing the read-gate's type, which is what surfaced the problem: typecheck failed atworkspace_tools_bridge.ts:499becauseTOOL_READ_SUBJECTwas declared as the wider union while every value it holds is a session-action subject. Naming the narrower set fixes the call site and documents the distinction.A note on what this does not grant
Widening the role gate does not by itself make these surfaces readable, and
allowed: truemust not be read as "the whole org":documentsandtasksnarrow further to the caller's team and project visibility;conversationsnarrows further still to its assignment scope —passesAssignmentScopeinrls_rules.tsmakes a conversation assigned to nobody admin-triage-only, and otherwise requires the caller to be the assignee or in the assigned team. The role matrix grantsconversations: READ_ONLYto every member, so the role check is necessary but not sufficient for that subject.The
AgentReadSubjectdoc comment records this so the next caller does not have to rediscover it.agent_read_access.tsstill owns no rules of its own, per its module contract.Verification
bun run checkclean — 438 tests pass acrossconvex/sandbox,convex/lib/rls,convex/node_only/sandboxand the chat tool suite; typecheck, oxlint, oxfmt clean; SAST 0 findings.Both new guards were mutation-tested — seen red before being accepted:
tasks: READ_ONLYfrom the member rowv.literal('projects')from the wire validator