Skip to content

feat(platform): keep archived work searchable and label it as archived - #3007

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/archived-search-context
Aug 18, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/archived-search-context

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

An archived project's tasks, and the project itself, were filtered out of rag_search. They are returned now, labelled as archived, so chat can cite a retired project and say it is retired.

Why

Archiving a project made its work invisible to chat. A retired project is often the only record of a decision, so hiding it makes chat worse at the questions history answers.

The exclusion was mine, in #3002 (convex/tasks/search_for_chat.ts:65,96). It followed the plan, which assumed archive should hide.

What changed

Two fields on a search result, because they are two different facts:

  • archived — the result itself is archived
  • projectArchived — the project it belongs to is archived

A live task in a retired project may still be work nobody closed. An archived task is not. Both fields can be true at once, and each is omitted when false, so a live result in a live project carries neither.

A document has no archive state of its own. projectArchived is the only field it can carry, which is accurate rather than a gap.

Nothing decides what the assistant says. The fields sit beside status and priority as data it may use. No sentence is appended, and no rule is added to the persona — lib/chat/assistant.test.ts forbids that class of rule there.

Two supporting changes:

  • resolveKnowledgeAccess returns archivedProjectIds, collected in the walk it already runs over every org project. Labelling costs no extra reads.
  • KnowledgeSource carries projectId, selected from the corpus row's existing scope stamp. Web pages select NULL.

Risk

archivedProjectIds is always a subset of projectIds. A project the caller cannot read appears in neither, so the field cannot leak that such a project exists. There is a test for it.

Retrieval scope is otherwise unchanged. The field is used for labelling only, never to narrow what a search returns.

Tests

Three layers, because the first draft tested only the top one:

  • the chat legs label correctly, including a live task in an archived project
  • searchTasksForChat and searchProjectsForChat return archived rows through convex-test
  • resolveKnowledgeAccessForUser collects archived ids and keeps them a subset

Mutations that turn tests red: collapsing the two fields into one, re-excluding archived tasks, re-excluding archived projects, dropping the archived-id collection, and labelling documents unconditionally.

Two mutations survived the first round — re-excluding archived tasks, and dropping the id collection. Both survived because the chat tests mock the query and the resolver. That is what the two lower layers now cover.

One existing assertion changed rather than being weakened. corpus.test.ts asserted the SQL contains no d.project_id for an org-wide caller, meaning no scope clause. The column is now selected either way, so the assertion checks for the predicate d.project_id = ANY.

Scope

Closes the retrieval half of #2999. The issue also asked whether archive should exclude; that is now answered as no, with labelling instead.

Not included: any UI change. The Documents list and the projects list still hide archived rows by their own rules, which is unaffected.

Gate: typecheck, oxlint --type-aware, oxfmt, SAST 0 findings, migrations:check (no migration), platform 75,158 tests.

An archived project's tasks and the project itself were filtered out of
rag_search. They are returned now, with two data fields that say what is
archived, so chat can cite a retired project and say it is retired.

Two fields, because they are two different facts. `archived` means the result
itself is archived. `projectArchived` means the project it belongs to is
archived. A live task in a retired project may still be work nobody closed; an
archived task is not. Both can be true at once, and each is omitted when false.

A document has no archive state of its own, so `projectArchived` is the only
field it can carry. That is the case this started from: a document filed under a
retired project stays retrievable and citable, with the context attached.

Nothing decides what the assistant says. The fields sit beside `status` and
`priority` as data it may use. No sentence is appended and no rule is added to
the persona, which `lib/chat/assistant.test.ts` forbids anyway.

`resolveKnowledgeAccess` returns `archivedProjectIds` from the walk it already
runs over every org project, so labelling costs no extra reads. It is always a
subset of `projectIds`: a project the caller cannot read is named in neither, so
the field cannot leak the existence of one.

`KnowledgeSource` carries `projectId`, selected from the corpus row's existing
scope stamp. Web pages select NULL for it. The `corpus.test.ts` assertion that
no scope clause is emitted for an org-wide caller now checks for the predicate
`d.project_id = ANY` rather than the bare column, since the column is selected
either way and is not a clause.

Closes the retrieval half of #2999.
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