Repository navigation
feat(platform): let chat see the organization's tasks and projects - #3002
Merged
Merged
Conversation
Asked about open project tasks, chat recommended Asana, Monday.com and Jira.
That was not a model failure: `rag_search` ran five legs — documents, crawled
pages, knowledge entries, contacts, products, websites — and none of them was
work, so a healthy knowledge base still answered nothing about the board.
Adds legs 6 and 7. Both take the readable project set the turn already resolved
(`KnowledgeAccessScope.projectIds`, memoised) and filter to it: a task has no ACL
of its own, so its parent project's is the only correct filter. Passing
`organizationId` alone to an RLS-bypassing query — the shape the contacts and
products legs use safely, because those tables are org-scope-and-role only —
would have handed every project's board to any member. Archived rows are
excluded, matching every other surface.
Work rows carry a `ref`, unlike contacts and products. That is load-bearing: the
loadout stays at three tools, so `rag_fetch` is the only depth path, and a
refless row would have made depth unreachable — absent by accident rather than by
decision. `rag_fetch` grows a `task:` branch over `getTaskContextForAgent`
(built, previously no chat caller) returning description, comments, subtasks and
blockers.
A ref is not a capability. The fetch re-derives project visibility rather than
trusting the leg that minted the ref, because a ref can be replayed on a later
turn after access changed. Every negative outcome — malformed id, nonexistent
task, another organization, an unreadable project — answers one byte-identical
`not_found`, so the message cannot be used as an existence oracle over another
project's board, and the cheap scope check runs before the expensive context
join. Arg-validation failures are caught: `v.id('tasks')` throws on an invented
ref, which had to read as that same `not_found`.
Also fixes the second cause. `lib/chat/context.ts` and the persona contained no
mention of tasks or projects, so nothing told the model the product has a board
at all. The persona now states that the work lives here and that no external
tracker should be recommended — as fact, not as tool-ordering, which a test
already forbids in the persona and which rides the tool descriptions instead.
A task step reads as work rather than as a citation (`thinking.readingTask`), and
`searchingKnowledgeBase` is retuned: "Searching knowledge base" was wrong copy
once the search covers the board. Both are written natively per locale, and the
tutorial that quoted the old label is updated with it.
This was referenced Aug 18, 2026
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.
Part of #2992. Adds the tasks and projects legs, and the depth path that replaces the cancelled fourth tool.
The defect
Asked about open project tasks, chat recommended Asana, Monday.com and Jira. Not a model failure:
rag_searchran five legs — documents, crawled pages, knowledge entries, contacts, products, websites — and none was work. A healthy knowledge base still answered nothing about the board. And nothing in the prompt said the product has tasks, so naming a competitor was the honest completion.Legs 6 and 7
Both take the readable project set the turn already resolved (
KnowledgeAccessScope.projectIds, memoised) and filter to it.This is the part worth reviewing closely. A task has no ACL of its own —
tasks/access.tsdelegates to its parent project — so the parent's readable set is the only correct filter. PassingorganizationIdalone to an RLS-bypassing internal query is the shape legs 3–4 use safely, because contacts and products are org-scope-and-role only; copying it here would have handed every project's board to any member. Archived rows are excluded, matchingprojects/queries.tsand the task rollups.Question-aware matching via
matchMode: 'any'(#2983) — the entity legs substring-match the whole phrase, so a leg asking "does any row contain this entire sentence?" can never match a question.Depth without a fourth tool
Work rows carry a
ref, unlike contacts and products. That is load-bearing: the loadout stays at three, sorag_fetchis the only depth path, and a refless row would have made depth unreachable — absent by accident rather than by decision.rag_fetchgrows atask:branch overgetTaskContextForAgent(built, previously no chat caller), returning description, comments, subtasks and blockers.Projects deliberately do not get a fetchable body: their search row already holds everything (name, key, open/done counts), so fetching a
project:ref answersinvalid_argsexplaining that, rather than silently returning nothing.A ref is not a capability. The fetch re-derives project visibility instead of trusting the leg that minted the ref, because a ref can be replayed on a later turn after access changed — the same rule
filterRetrievableRagFileIdsapplies to document refs. Every negative outcome — malformed id, nonexistent task, another organization, an unreadable project — answers one byte-identicalnot_found, so the message cannot serve as an existence oracle over another project's board. The cheap scope check runs before the expensive context join, and arg-validation failures are caught:v.id('tasks')throws on an invented ref, which had to read as that samenot_found.The second cause
lib/chat/context.tsand the persona contained zero mentions of tasks or projects. The persona now states that the work lives in this workspace and that no external tracker should be recommended — as fact, not tool-ordering.assistant.test.tsforbids ordering rules in the persona (that steer rides the tool descriptions), and the first draft of this change violated it; the test caught it and the wording changed rather than the test.Rendering and copy
A task step reads as work, not a citation —
thinking.readingTask, sincesource-cards.tsxrenders onlyweb | document. AndsearchingKnowledgeBaseis retuned: "Searching knowledge base" is wrong copy once the search covers the board. Written natively per locale (DE keepsWorkspace, its shipped term at 13 uses vs 7Arbeitsbereich; FR usesespace de travail), andde-CHholds nothinkingkeys, so it correctly falls back tode.The tutorial quoted the old timeline label verbatim, so it would have gone stale — updated in all three locales, with FR's NBSP guillemet spacing preserved.
Tests
Eleven new cases across the legs and the fetch branch. Every new assertion mutation-tested — each of these turns the relevant tests red:
ref(the exact trap that would have removed depth)Two existing tests were updated rather than weakened: the
sourcesmap now has two more keys, and "only document and web-page rows carry a ref" is no longer true — replaced with the new truth plus a check that project rows stay inline.Gate: typecheck,
oxlint --type-aware(which caught an unsafe assertion bareoxlintmissed — now a real type predicate), oxfmt, SAST 0 findings,migrations:check(no migration), platform 75,111 tests, UI 1,167, docs 194.Note on
api.d.tsThe new module's entry was added by hand, alphabetically.
convex codegenneeds a reachable deployment and the worktree has none, so this is the same path the repo's other worktree PRs take — worth a glance to confirm it matches what codegen would emit.