Skip to content

feat(platform): let chat see the organization's tasks and projects - #3002

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/chat-work-legs
Aug 18, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/chat-work-legs

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

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_search ran 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.ts delegates to its parent project — so the parent's readable set is the only correct filter. Passing organizationId alone 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, matching projects/queries.ts and 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, 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.

Projects deliberately do not get a fetchable body: their search row already holds everything (name, key, open/done counts), so fetching a project: ref answers invalid_args explaining 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 filterRetrievableRagFileIds applies to document refs. Every negative outcome — malformed id, nonexistent task, another organization, an unreadable project — answers one byte-identical not_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 same not_found.

The second cause

lib/chat/context.ts and 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.ts forbids 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, since source-cards.tsx renders only web | document. And searchingKnowledgeBase is retuned: "Searching knowledge base" is wrong copy once the search covers the board. Written natively per locale (DE keeps Workspace, its shipped term at 13 uses vs 7 Arbeitsbereich; FR uses espace de travail), and de-CH holds no thinking keys, so it correctly falls back to de.

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:

  • work rows carry no ref (the exact trap that would have removed depth)
  • skip the fetch-time project re-check
  • pass the whole org instead of the readable project set
  • make the refusal distinguishable (the existence oracle)
  • drop the arg-validation catch

Two existing tests were updated rather than weakened: the sources map 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 bare oxlint missed — 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.ts

The new module's entry was added by hand, alphabetically. convex codegen needs 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.

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.
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