Skip to content

feat(platform): let agent read tools name tasks, projects and conversations - #2984

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/work-read-subjects
Aug 17, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/work-read-subjects

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

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 — and tasks has no row in platformPermissions either, so authorizeRls would 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 platformPermissions row for tasks that mirrors projects on every role. 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. projects, conversations and conversationMessages already had rows.

Two lists that could silently disagree are now pinned.

  • AGENT_READ_SUBJECTS is a runtime array and AgentReadSubject derives from it, so the existing "an active member reads every workspace subject" test iterates the real list rather than its own copy of it.
  • Convex needs literal validators, so the wire union is still spelled by hand. A new test asserts it matches the array — a subject present in one and missing from the other is an argument-validation error at dispatch, invisible to the type checker.

SessionActionSubject is now its own name. resolveSessionActionContext answers a different question — may this run act here, given its automation's project binding — over a strict subset that excludes projects and conversations. It had been borrowing the read-gate's type, which is what surfaced the problem: typecheck failed at workspace_tools_bridge.ts:499 because TOOL_READ_SUBJECT was 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: true must not be read as "the whole org":

  • documents and tasks narrow further to the caller's team and project visibility;
  • conversations narrows further still to its assignment scope — passesAssignmentScope in rls_rules.ts makes 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 grants conversations: READ_ONLY to every member, so the role check is necessary but not sufficient for that subject.

The AgentReadSubject doc comment records this so the next caller does not have to rediscover it. agent_read_access.ts still owns no rules of its own, per its module contract.

Verification

bun run check clean — 438 tests pass across convex/sandbox, convex/lib/rls, convex/node_only/sandbox and the chat tool suite; typecheck, oxlint, oxfmt clean; SAST 0 findings.

Both new guards were mutation-tested — seen red before being accepted:

Mutation Result
drop tasks: READ_ONLY from the member row an active member reads every workspace subject fails
drop v.literal('projects') from the wire validator the wire validator lists exactly the subjects the resolver knows fails

…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".
@Israeltheminer
Israeltheminer merged commit 0a40bf7 into main Aug 17, 2026
50 checks passed
@Israeltheminer
Israeltheminer deleted the feat/work-read-subjects branch August 17, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant