Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(inbox): require owner-triggered runs to read archived notifications (MUL-9411) (#10739)
Multica Eve0f3e15f1d9dc
diff --git a/apps/docs/content/docs/concepts.fr.mdx b/apps/docs/content/docs/concepts.fr.mdxindex fe421bc10c..03cec0fe7a 100644--- a/apps/docs/content/docs/concepts.fr.mdx+++ b/apps/docs/content/docs/concepts.fr.mdx@@ -51,7 +51,7 @@ Un moyen d'échanger qui n'est rattaché à aucune tâche — idéal pour les qu### Boîte de réception-Le centre de notifications d'un membre : l'activité sur les tâches auxquelles il est abonné, les mentions et les assignations y arrivent. Les agents reçoivent directement des exécutions ; lire la liste des notifications actives du propriétaire du runtime exige une exécution déclenchée par ce propriétaire. Voir [Boîte de réception et abonnements](/inbox).+Le centre de notifications d'un membre : l'activité sur les tâches auxquelles il est abonné, les mentions et les assignations y arrivent. Les agents reçoivent directement des exécutions ; lire les notifications actives ou archivées du propriétaire du runtime exige une exécution déclenchée par ce propriétaire. Voir [Boîte de réception et abonnements](/inbox).### Automatisationdiff --git a/apps/docs/content/docs/concepts.ja.mdx b/apps/docs/content/docs/concepts.ja.mdxindex 5f8842cc6b..c2a0596f39 100644--- a/apps/docs/content/docs/concepts.ja.mdx+++ b/apps/docs/content/docs/concepts.ja.mdx@@ -51,7 +51,7 @@ import { ConceptMapDemo } from "@/components/demos/concept-map-demo";### インボックス-メンバーの通知センターで、購読しているタスクの動き、メンション、割り当てがここに集まります。エージェントは実行を直接受け取り、ランタイム所有者のアクティブな通知一覧を読むには、その所有者本人が開始した実行が必要です。詳しくは[インボックスと購読](/inbox)を参照してください。+メンバーの通知センターで、購読しているタスクの動き、メンション、割り当てがここに集まります。エージェントは実行を直接受け取り、ランタイム所有者のアクティブまたはアーカイブ済みの通知を読むには、その所有者本人が開始した実行が必要です。詳しくは[インボックスと購読](/inbox)を参照してください。### オートパイロットdiff --git a/apps/docs/content/docs/concepts.ko.mdx b/apps/docs/content/docs/concepts.ko.mdxindex cb6cd1a01b..ce42eeeed1 100644--- a/apps/docs/content/docs/concepts.ko.mdx+++ b/apps/docs/content/docs/concepts.ko.mdx@@ -51,7 +51,7 @@ import { ConceptMapDemo } from "@/components/demos/concept-map-demo";### 인박스-멤버를 위한 알림 센터입니다. 구독한 태스크의 활동, 멘션, 할당 알림이 이곳에 모입니다. 에이전트는 실행을 직접 받으며, 런타임 소유자의 활성 알림 목록을 읽으려면 해당 소유자 본인이 시작한 실행이어야 합니다. 자세한 내용은 [인박스와 구독](/inbox)을 참고하세요.+멤버를 위한 알림 센터입니다. 구독한 태스크의 활동, 멘션, 할당 알림이 이곳에 모입니다. 에이전트는 실행을 직접 받으며, 런타임 소유자의 활성 또는 보관된 알림을 읽으려면 해당 소유자 본인이 시작한 실행이어야 합니다. 자세한 내용은 [인박스와 구독](/inbox)을 참고하세요.### 오토파일럿diff --git a/apps/docs/content/docs/concepts.mdx b/apps/docs/content/docs/concepts.mdxindex 1adbc133f0..4d3b8f7839 100644--- a/apps/docs/content/docs/concepts.mdx+++ b/apps/docs/content/docs/concepts.mdx@@ -51,7 +51,7 @@ A way to talk that is not attached to an issue — good for questions and quick### Inbox-A member's notification center: activity on subscribed issues, mentions, and assignments all land here. Agents receive runs directly; reading the runtime owner's active notification list requires a run triggered by that owner. See [Inbox and subscriptions](/inbox).+A member's notification center: activity on subscribed issues, mentions, and assignments all land here. Agents receive runs directly; reading the runtime owner's active or archived notifications requires a run triggered by that owner. See [Inbox and subscriptions](/inbox).### Autopilotdiff --git a/apps/docs/content/docs/concepts.zh-Hant.mdx b/apps/docs/content/docs/concepts.zh-Hant.mdxindex ffa1e53e64..a30cc28a35 100644--- a/apps/docs/content/docs/concepts.zh-Hant.mdx+++ b/apps/docs/content/docs/concepts.zh-Hant.mdx@@ -51,7 +51,7 @@ AI 代理的一次具體執行記錄。每次觸發產生一次執行,由某### 收件箱-成員的通知中心:訂閱的任務動態、提及和分配都匯聚在這裡。AI 代理直接接收執行;讀取執行環境擁有者的活躍通知列表,需要由該擁有者本人觸發。詳見[收件箱與訂閱](/inbox)。+成員的通知中心:訂閱的任務動態、提及和分配都匯聚在這裡。AI 代理直接接收執行;讀取執行環境擁有者的活躍或封存通知,需要由該擁有者本人觸發。詳見[收件箱與訂閱](/inbox)。### 自動化diff --git a/apps/docs/content/docs/concepts.zh.mdx b/apps/docs/content/docs/concepts.zh.mdxindex 9324ee313d..ec812f8bc9 100644--- a/apps/docs/content/docs/concepts.zh.mdx+++ b/apps/docs/content/docs/concepts.zh.mdx@@ -51,7 +51,7 @@ import { ConceptMapDemo } from "@/components/demos/concept-map-demo";### 收件箱-成员的通知中心:订阅的任务动态、提及和分配都汇聚在这里。智能体直接接收运行;读取运行环境所有者的活跃通知列表,需要由该所有者本人触发。详见[收件箱与订阅](/inbox)。+成员的通知中心:订阅的任务动态、提及和分配都汇聚在这里。智能体直接接收运行;读取运行环境所有者的活跃或归档通知,需要由该所有者本人触发。详见[收件箱与订阅](/inbox)。### 自动化diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdxindex 0d4bdfdba0..a0b2532e43 100644--- a/apps/docs/content/docs/inbox.fr.mdx+++ b/apps/docs/content/docs/inbox.fr.mdx@@ -55,7 +55,7 @@ La page de la tâche signale un tel abonnement par **Mises à jour clés**. Son## Les agents et la boîte de réception-Les notifications appartiennent aux membres de l'espace de travail. Pour la liste des notifications actives utilisée par `multica inbox list`, un agent peut lire les notifications du propriétaire du runtime uniquement si le serveur vérifie que ce propriétaire est la personne à l'origine de l'exécution. Cette identité est transmise dans les chaînes de délégation entre agents. Les exécutions déclenchées par une autre personne ou sans personne vérifiable, ainsi que les identifiants de nœud cloud sans liaison à une exécution, ne peuvent pas lire cette liste active. Cette garantie couvre uniquement la liste active ; les listes archivées et reportées, les compteurs de non-lus et les interfaces d'écriture conservent leurs permissions actuelles en attendant un traitement séparé.+Les notifications appartiennent aux membres de l'espace de travail. Pour la liste des notifications actives utilisée par `multica inbox list` et pour les notifications archivées, un agent peut lire les notifications du propriétaire du runtime uniquement si le serveur vérifie que ce propriétaire est la personne à l'origine de l'exécution. Cette identité est transmise dans les chaînes de délégation entre agents. Les exécutions déclenchées par une autre personne ou sans personne vérifiable, ainsi que les identifiants de nœud cloud sans liaison à une exécution, ne peuvent pas les lire. Cette garantie couvre uniquement la liste active et les archives ; la liste reportée, les compteurs de non-lus et les interfaces d'écriture conservent leurs permissions actuelles en attendant un traitement séparé.@mentionner un agent dans un commentaire, lui assigner une tâche ou déclencher une automatisation crée directement une exécution ; aucune notification n'est laissée à l'agent. `@all` ne notifie que les membres.diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdxindex 83caac5930..c5d916d841 100644--- a/apps/docs/content/docs/inbox.ja.mdx+++ b/apps/docs/content/docs/inbox.ja.mdx@@ -55,7 +55,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";## エージェントとインボックス-インボックスの通知はワークスペースメンバーに属します。`multica inbox list` が使うアクティブな通知一覧では、実行を開始した上流のユーザーがランタイム所有者本人であるとサーバーが確認できた場合だけ、エージェントがその所有者の通知を読み取れます。このユーザー情報はエージェントの委任チェーンで引き継がれます。他の人が開始した実行、開始した人を確認できない実行、タスクとの紐付けがないクラウドノードの認証情報では、このアクティブ一覧を読み取れません。この保証はアクティブ一覧のみが対象です。アーカイブ済み・スヌーズ中の一覧、未読件数、書き込み API は従来の権限を維持し、別途対応します。+インボックスの通知はワークスペースメンバーに属します。`multica inbox list` が使うアクティブな通知一覧とアーカイブ済みの通知では、実行を開始した上流のユーザーがランタイム所有者本人であるとサーバーが確認できた場合だけ、エージェントがその所有者の通知を読み取れます。このユーザー情報はエージェントの委任チェーンで引き継がれます。他の人が開始した実行、開始した人を確認できない実行、タスクとの紐付けがないクラウドノードの認証情報では、これらを読み取れません。この保証はアクティブ一覧とアーカイブのみが対象です。スヌーズ中の一覧、未読件数、書き込み API は従来の権限を維持し、別途対応します。コメントでの @メンション、タスクの割り当て、オートパイロットのトリガーは、直接実行を作成し、エージェントに通知は残しません。`@all` もメンバーにのみ通知します。diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdxindex d092305265..2965d01e98 100644--- a/apps/docs/content/docs/inbox.ko.mdx+++ b/apps/docs/content/docs/inbox.ko.mdx@@ -55,7 +55,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";## 에이전트와 인박스-인박스 알림은 워크스페이스 멤버의 데이터입니다. `multica inbox list`가 사용하는 활성 알림 목록에서는 서버가 실행을 시작한 상위 사용자가 런타임 소유자 본인임을 확인한 경우에만 에이전트가 해당 소유자의 알림을 읽을 수 있습니다. 이 사용자 정보는 에이전트 위임 체인을 따라 상속됩니다. 다른 사람이 시작한 실행, 시작한 사람을 확인할 수 없는 실행, 태스크에 연결되지 않은 클라우드 노드 자격 증명으로는 이 활성 목록을 읽을 수 없습니다. 이 보장은 활성 목록에만 적용됩니다. 보관 및 다시 알림 목록, 읽지 않은 알림 수, 쓰기 API의 권한은 현재 상태를 유지하며 별도로 처리합니다.+인박스 알림은 워크스페이스 멤버의 데이터입니다. `multica inbox list`가 사용하는 활성 알림 목록과 보관된 알림에서는 서버가 실행을 시작한 상위 사용자가 런타임 소유자 본인임을 확인한 경우에만 에이전트가 해당 소유자의 알림을 읽을 수 있습니다. 이 사용자 정보는 에이전트 위임 체인을 따라 상속됩니다. 다른 사람이 시작한 실행, 시작한 사람을 확인할 수 없는 실행, 태스크에 연결되지 않은 클라우드 노드 자격 증명으로는 이를 읽을 수 없습니다. 이 보장은 활성 목록과 보관함에만 적용됩니다. 다시 알림 목록, 읽지 않은 알림 수, 쓰기 API의 권한은 현재 상태를 유지하며 별도로 처리합니다.댓글에서 에이전트를 @멘션하거나 태스크를 에이전트에게 할당하거나 자동화를 트리거하면 실행이 직접 생성되며, 에이전트에게 알림을 남기지 않습니다. `@all`도 멤버에게만 알립니다.diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdxindex ef555b46a8..b608ea333d 100644--- a/apps/docs/content/docs/inbox.mdx+++ b/apps/docs/content/docs/inbox.mdx@@ -55,7 +55,7 @@ The issue page marks such a subscription **Key updates only**. Its menu offers *## Agents and the inbox-Inbox notifications belong to workspace members. For the active notification list used by `multica inbox list`, an agent may read the runtime owner's notifications only when the server verifies that the owner is the upstream human who triggered the run. This identity follows agent delegation chains. Runs triggered by another person or without a verifiable human, and cloud-node credentials without a task binding, cannot read that active list. This guarantee covers only the active list; archived and snoozed lists, unread counts and write endpoints retain their current permissions pending separate work.+Inbox notifications belong to workspace members. For the active notification list used by `multica inbox list` and for archived notifications, an agent may read the runtime owner's notifications only when the server verifies that the owner is the upstream human who triggered the run. This identity follows agent delegation chains. Runs triggered by another person or without a verifiable human, and cloud-node credentials without a task binding, cannot read them. This guarantee covers only the active and archived lists; the snoozed list, unread counts and write endpoints retain their current permissions pending separate work.@-mentioning an agent in a comment, assigning an issue to it, or triggering an autopilot creates a run directly; no notification is left for the agent. `@all` notifies members only.diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdxindex 9ac7ecf6db..5212a77912 100644--- a/apps/docs/content/docs/inbox.zh-Hant.mdx+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx@@ -55,7 +55,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";## AI 代理與收件箱-收件箱通知屬於工作區成員。對於 `multica inbox list` 使用的活躍通知列表,只有伺服器驗證執行的上游觸發人就是執行環境擁有者時,AI 代理才能讀取該擁有者的列表。這個身分會沿 AI 代理呼叫鏈繼承。由他人觸發、沒有可驗證觸發人的執行,以及沒有任務綁定的雲端節點憑證,都不能讀取該活躍列表。此保證只涵蓋活躍列表;封存、稍後提醒、未讀數和寫入介面沿用現有權限,另案處理。+收件箱通知屬於工作區成員。對於 `multica inbox list` 使用的活躍通知列表和封存通知,只有伺服器驗證執行的上游觸發人就是執行環境擁有者時,AI 代理才能讀取該擁有者的列表。這個身分會沿 AI 代理呼叫鏈繼承。由他人觸發、沒有可驗證觸發人的執行,以及沒有任務綁定的雲端節點憑證,都不能讀取。此保證只涵蓋活躍列表和封存;稍後提醒、未讀數和寫入介面沿用現有權限,另案處理。在評論中 @ AI 代理、把任務分配給 AI 代理或觸發自動化,都會直接建立一次執行,不會給 AI 代理留通知。`@all` 也只通知成員。diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdxindex e1b06a3d75..4120293436 100644--- a/apps/docs/content/docs/inbox.zh.mdx+++ b/apps/docs/content/docs/inbox.zh.mdx@@ -55,7 +55,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";## 智能体与收件箱-收件箱通知属于工作区成员。对于 `multica inbox list` 使用的活跃通知列表,只有服务端验证运行的上游触发人就是运行环境所有者时,智能体才能读取该所有者的列表。这个身份会沿智能体调用链继承。由他人触发、没有可验证触发人的运行,以及没有任务绑定的云节点凭证,都不能读取该活跃列表。此保证只覆盖活跃列表;归档、稍后提醒、未读数和写接口沿用现有权限,另案处理。+收件箱通知属于工作区成员。对于 `multica inbox list` 使用的活跃通知列表和归档通知,只有服务端验证运行的上游触发人就是运行环境所有者时,智能体才能读取该所有者的列表。这个身份会沿智能体调用链继承。由他人触发、没有可验证触发人的运行,以及没有任务绑定的云节点凭证,都不能读取。此保证只覆盖活跃列表和归档;稍后提醒、未读数和写接口沿用现有权限,另案处理。在评论中 @智能体、把任务分配给智能体或触发自动化,都会直接创建一次运行,不会给智能体留通知。`@all` 也只通知成员。diff --git a/server/internal/handler/inbox.go b/server/internal/handler/inbox.goindex c725749615..9fed9434ee 100644--- a/server/internal/handler/inbox.go+++ b/server/internal/handler/inbox.go@@ -208,7 +208,7 @@ func (h *Handler) ListInbox(w http.ResponseWriter, r *http.Request) {return}- if !h.requireInboxListAccess(w, r, userID, wsUUID) {+ if !h.requireInboxOwnerAccess(w, r, userID, wsUUID) {return}@@ -239,9 +239,10 @@ func (h *Handler) ListInbox(w http.ResponseWriter, r *http.Request) {}// Task tokens identify the runtime owner, not necessarily the human who asked-// the agent to act. Personal notifications require that same human upstream.-// Auth strips client identity headers and stamps the task/agent from the token.-func (h *Handler) requireInboxListAccess(w http.ResponseWriter, r *http.Request, userID string, workspaceID pgtype.UUID) bool {+// the agent to act. Reading the owner's notifications (active list and the+// archive) requires that same human upstream. Auth strips client identity+// headers and stamps the task/agent from the token.+func (h *Handler) requireInboxOwnerAccess(w http.ResponseWriter, r *http.Request, userID string, workspaceID pgtype.UUID) bool {source := r.Header.Get("X-Actor-Source")if source == "" {return true@@ -307,6 +308,10 @@ func (h *Handler) ListArchivedInbox(w http.ResponseWriter, r *http.Request) {return}+ if !h.requireInboxOwnerAccess(w, r, userID, wsUUID) {+ return+ }+hidden, ok := h.requestHiddenProjects(w, r, workspaceID)if !ok {returndiff --git a/server/internal/handler/inbox_access_test.go b/server/internal/handler/inbox_access_test.goindex c75ec21944..0f63fd5338 100644--- a/server/internal/handler/inbox_access_test.go+++ b/server/internal/handler/inbox_access_test.go@@ -31,6 +31,33 @@ func inboxTaskCredential(t *testing.T, taskID, agentID, workspaceID, userID strireturn token}+// Every Inbox read that returns the owner's notifications is gated by+// requireInboxOwnerAccess; the access matrix runs against each of them.+type inboxOwnerRead struct {+ name, path, query string+ handler func(*Handler, http.ResponseWriter, *http.Request)+}++var inboxOwnerReads = []inboxOwnerRead{+ {"active", "/api/inbox", "ListInboxItems", (*Handler).ListInbox},+ {"archived", "/api/inbox/archived", "ListArchivedInboxItems", (*Handler).ListArchivedInbox},+ {"archived page", "/api/inbox/archived/page", "ListArchivedInboxPage", (*Handler).ListArchivedInboxPage},+ {"archived facets", "/api/inbox/archived/facets", "ArchivedInboxFacets", (*Handler).GetArchivedInboxFacets},+}++func (e inboxOwnerRead) serve(h *Handler, cloud *auth.CloudPATVerifier) http.HandlerFunc {+ return middleware.Auth(testHandler.Queries, nil, cloud, nil)(+ middleware.RequireWorkspaceMember(testHandler.Queries)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ e.handler(h, w, r)+ })),+ ).ServeHTTP+}++func (e inboxOwnerRead) request(token, workspaceID string) *http.Request {+ return testutil.WithHeaders(testutil.JSONRequest(http.MethodGet, e.path, nil),+ "Authorization", "Bearer "+token, "X-Workspace-ID", workspaceID)+}+type inboxAccessFailureDB struct {db.DBTXquery string@@ -47,8 +74,10 @@ func (d *inboxAccessFailureDB) QueryRow(ctx context.Context, sql string, args ..}func (d *inboxAccessFailureDB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {- if strings.HasPrefix(sql, "-- name: ListInboxItems :many\n") {- d.inboxReads+++ for _, e := range inboxOwnerReads {+ if strings.HasPrefix(sql, "-- name: "+e.query+" :many\n") {+ d.inboxReads+++ }}return d.DBTX.Query(ctx, sql, args...)}@@ -62,45 +91,42 @@ func TestListInboxAccessLookupErrors(t *testing.T) {})token := inboxTaskCredential(t, taskID, agentID, testWorkspaceID, testUserID)const privateDetails = "private-inbox-database-host-and-query"- for _, query := range []string{"GetAgentTask", "GetAgentRuntimeForWorkspace"} {- for _, tc := range []struct {- name string- err error- status int- }{- {"missing", pgx.ErrNoRows, http.StatusForbidden},- {"wrapped missing", fmt.Errorf("%s: %w", privateDetails, pgx.ErrNoRows), http.StatusForbidden},- {"deadline", fmt.Errorf("%s: %w", privateDetails, context.DeadlineExceeded), http.StatusInternalServerError},- {"statement timeout", &pgconn.PgError{Code: "57014", Message: privateDetails}, http.StatusInternalServerError},- {"connection failure", errors.New(privateDetails), http.StatusInternalServerError},- } {- t.Run(query+"/"+tc.name, func(t *testing.T) {- faults := &inboxAccessFailureDB{DBTX: testPool, query: query, err: tc.err}- h := *testHandler- h.Queries = db.New(faults)- handler := middleware.Auth(testHandler.Queries, nil, nil, nil)(- middleware.RequireWorkspaceMember(testHandler.Queries)(http.HandlerFunc(h.ListInbox)),- ).ServeHTTP- body := testutil.Call(t, handler, inboxCredentialRequest(token, testWorkspaceID)).Want(tc.status).Map()- if faults.failures != 1 || faults.inboxReads != 0 {- t.Fatalf("lookup failures=%d inbox reads=%d; want one failure and no Inbox read", faults.failures, faults.inboxReads)- }- publicError, ok := body["error"].(string)- if len(body) != 1 || !ok || publicError == "" || strings.Contains(fmt.Sprint(body), privateDetails) {- t.Fatalf("response must contain only a protected public error: %v", body)- }- if tc.status == http.StatusInternalServerError && body["error"] != "failed to resolve inbox access" {- t.Fatalf("service failure reported as an authorization error: %v", body)- }- })+ for _, e := range inboxOwnerReads {+ for _, query := range []string{"GetAgentTask", "GetAgentRuntimeForWorkspace"} {+ for _, tc := range []struct {+ name string+ err error+ status int+ }{+ {"missing", pgx.ErrNoRows, http.StatusForbidden},+ {"wrapped missing", fmt.Errorf("%s: %w", privateDetails, pgx.ErrNoRows), http.StatusForbidden},+ {"deadline", fmt.Errorf("%s: %w", privateDetails, context.DeadlineExceeded), http.StatusInternalServerError},+ {"statement timeout", &pgconn.PgError{Code: "57014", Message: privateDetails}, http.StatusInternalServerError},+ {"connection failure", errors.New(privateDetails), http.StatusInternalServerError},+ } {+ t.Run(e.name+"/"+query+"/"+tc.name, func(t *testing.T) {+ faults := &inboxAccessFailureDB{DBTX: testPool, query: query, err: tc.err}+ h := *testHandler+ h.Queries = db.New(faults)+ body := testutil.Call(t, e.serve(&h, nil), e.request(token, testWorkspaceID)).Want(tc.status).Map()+ if faults.failures != 1 || faults.inboxReads != 0 {+ t.Fatalf("lookup failures=%d inbox reads=%d; want one failure and no Inbox read", faults.failures, faults.inboxReads)+ }+ publicError, ok := body["error"].(string)+ if len(body) != 1 || !ok || publicError == "" || strings.Contains(fmt.Sprint(body), privateDetails) {+ t.Fatalf("response must contain only a protected public error: %v", body)+ }+ if tc.status == http.StatusInternalServerError && body["error"] != "failed to resolve inbox access" {+ t.Fatalf("service failure reported as an authorization error: %v", body)+ }+ })+ }}}}func inboxAccessHandler(cloud *auth.CloudPATVerifier) http.HandlerFunc {- return middleware.Auth(testHandler.Queries, nil, cloud, nil)(- middleware.RequireWorkspaceMember(testHandler.Queries)(http.HandlerFunc(testHandler.ListInbox)),- ).ServeHTTP+ return inboxOwnerReads[0].serve(testHandler, cloud)}func inboxCredentialRequest(token, workspaceID string) *http.Request {@@ -152,7 +178,11 @@ func TestListInboxTaskCredentialAccess(t *testing.T) {agentID = dbfx.Agent(t, "Token agent", runtimeID)}token := inboxTaskCredential(t, taskID, agentID, testWorkspaceID, testUserID)- testutil.Call(t, inboxAccessHandler(nil), inboxCredentialRequest(token, testWorkspaceID)).Want(tc.want)+ for _, e := range inboxOwnerReads {+ t.Run(e.name, func(t *testing.T) {+ testutil.Call(t, e.serve(testHandler, nil), e.request(token, testWorkspaceID)).Want(tc.want)+ })+ }})}}@@ -164,16 +194,19 @@ func TestListInboxRejectsForgedTaskIdentityAndWorkspace(t *testing.T) {allowedTask := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, "status": "running", "originator_user_id": testUserID, "accountable_user_id": testUserID})deniedTask := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, "status": "running", "originator_user_id": other, "accountable_user_id": other})token := inboxTaskCredential(t, deniedTask, agentID, testWorkspaceID, testUserID)- req := inboxCredentialRequest(token, testWorkspaceID)- req = testutil.WithHeaders(req, "X-Task-ID", allowedTask, "X-Agent-ID", agentID,- "X-Actor-Source", "member", "X-User-ID", other, "X-Originator-User-ID", testUserID)- req.URL.RawQuery = "originator_user_id=" + testUserID + "&recipient_id=" + other- testutil.Call(t, inboxAccessHandler(nil), req).Want(http.StatusForbidden)-foreignWorkspace := dbfx.Workspace(t, "Foreign inbox", "inbox-forged-ws-"+uuid.NewString())dbfx.Member(t, foreignWorkspace, testUserID, "owner")allowedToken := inboxTaskCredential(t, allowedTask, agentID, testWorkspaceID, testUserID)- testutil.Call(t, inboxAccessHandler(nil), inboxCredentialRequest(allowedToken, foreignWorkspace)).Want(http.StatusForbidden)+ for _, e := range inboxOwnerReads {+ t.Run(e.name, func(t *testing.T) {+ req := testutil.WithHeaders(e.request(token, testWorkspaceID), "X-Task-ID", allowedTask, "X-Agent-ID", agentID,+ "X-Actor-Source", "member", "X-User-ID", other, "X-Originator-User-ID", testUserID)+ req.URL.RawQuery = "originator_user_id=" + testUserID + "&recipient_id=" + other+ testutil.Call(t, e.serve(testHandler, nil), req).Want(http.StatusForbidden)++ testutil.Call(t, e.serve(testHandler, nil), e.request(allowedToken, foreignWorkspace)).Want(http.StatusForbidden)+ })+ }}func TestListInboxCloudPATCannotBorrowTaskIdentity(t *testing.T) {@@ -185,9 +218,13 @@ func TestListInboxCloudPATCannotBorrowTaskIdentity(t *testing.T) {runtimeID := dbfx.Runtime(t, "Cloud inbox runtime")agentID := dbfx.Agent(t, "Cloud inbox agent", runtimeID)taskID := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, "status": "running", "originator_user_id": testUserID, "accountable_user_id": testUserID})- req := testutil.WithHeaders(inboxCredentialRequest("mcn_inbox-test", testWorkspaceID),- "X-Actor-Source", "task_token", "X-Task-ID", taskID, "X-Agent-ID", agentID)- testutil.Call(t, inboxAccessHandler(verifier), req).Want(http.StatusForbidden)+ for _, e := range inboxOwnerReads {+ t.Run(e.name, func(t *testing.T) {+ req := testutil.WithHeaders(e.request("mcn_inbox-test", testWorkspaceID),+ "X-Actor-Source", "task_token", "X-Task-ID", taskID, "X-Agent-ID", agentID)+ testutil.Call(t, e.serve(testHandler, verifier), req).Want(http.StatusForbidden)+ })+ }}func TestListInboxHumanCredentialsAndReadOnlyIsolation(t *testing.T) {@@ -299,3 +336,56 @@ func TestListInboxDelegatedOriginatorAndProjectVisibility(t *testing.T) {}t.Logf("delegation issue counter: %d -> %d", counterBefore, counterAfter)}++func TestArchivedInboxOwnerReadIsolation(t *testing.T) {+ other := createPlainMember(t, "inbox-archived-recipient-"+uuid.NewString()+"@example.test")+ foreignWorkspace := dbfx.Workspace(t, "Foreign archived inbox", "inbox-archived-"+uuid.NewString())+ dbfx.Member(t, foreignWorkspace, testUserID, "owner")+ newArchived := func(workspaceID, recipientID string) string {+ return dbfx.Insert(t, "inbox_item", testutil.Cols{"workspace_id": workspaceID, "archived": true,+ "recipient_type": "member", "recipient_id": recipientID, "type": "system", "severity": "info", "title": "Private archived notice"})+ }+ own := newArchived(testWorkspaceID, testUserID)+ otherItem := newArchived(testWorkspaceID, other)+ foreign := newArchived(foreignWorkspace, testUserID)+ pat := "mul_" + uuid.NewString()+ dbfx.Insert(t, "personal_access_token", testutil.Cols{"user_id": testUserID, "name": "Archived inbox test", "token_hash": auth.HashToken(pat), "token_prefix": pat[:12]})+ runtimeID := dbfx.Runtime(t, "Own archived inbox runtime")+ agentID := dbfx.Agent(t, "Own archived inbox agent", runtimeID)+ taskID := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, "status": "running", "originator_user_id": testUserID, "accountable_user_id": testUserID})+ taskToken := inboxTaskCredential(t, taskID, agentID, testWorkspaceID, testUserID)+ reads := map[string]func(*testing.T, *http.Request) []InboxItemResponse{+ "archived": func(t *testing.T, req *http.Request) []InboxItemResponse {+ var items []InboxItemResponse+ testutil.Call(t, inboxOwnerReads[1].serve(testHandler, nil), req).Want(http.StatusOK).JSON(&items)+ return items+ },+ "archived page": func(t *testing.T, req *http.Request) []InboxItemResponse {+ var page archivedInboxPageResponse+ testutil.Call(t, inboxOwnerReads[2].serve(testHandler, nil), req).Want(http.StatusOK).JSON(&page)+ return page.Items+ },+ }+ paths := map[string]string{"archived": inboxOwnerReads[1].path, "archived page": inboxOwnerReads[2].path}+ for _, cred := range []struct{ name, token string }{{"personal PAT", pat}, {"self-triggered task", taskToken}} {+ for name, read := range reads {+ t.Run(cred.name+"/"+name, func(t *testing.T) {+ req := testutil.WithHeaders(testutil.JSONRequest(http.MethodGet, paths[name]+"?recipient_id="+other, nil),+ "Authorization", "Bearer "+cred.token, "X-Workspace-ID", testWorkspaceID, "X-User-ID", other)+ found := false+ for _, item := range read(t, req) {+ if item.ID == otherItem || item.ID == foreign {+ t.Fatalf("another recipient or workspace leaked: %s", item.ID)+ }+ found = found || item.ID == own+ }+ if !found {+ t.Fatal("own archived notification missing")+ }+ if state := loadInboxItemState(t, own); state != (inboxItemState{archived: true}) {+ t.Fatalf("GET mutated state: %+v", state)+ }+ })+ }+ }+}diff --git a/server/internal/handler/inbox_archive.go b/server/internal/handler/inbox_archive.goindex db6a6bcf63..79be7d3c24 100644--- a/server/internal/handler/inbox_archive.go+++ b/server/internal/handler/inbox_archive.go@@ -46,7 +46,9 @@ var (archivedInboxNegatable = []string{"type", "actor", "status", "priority", "project", "assignee", "label", "dueDate"})-func parseArchivedInboxFilters(w http.ResponseWriter, r *http.Request) (db.ArchivedInboxFacetsParams, bool) {+// parseArchivedInboxFilters also gates the archive on owner access, so every+// archive read that goes through it shares the active list's protection.+func (h *Handler) parseArchivedInboxFilters(w http.ResponseWriter, r *http.Request) (db.ArchivedInboxFacetsParams, bool) {var p db.ArchivedInboxFacetsParamsuserID, ok := requireUserID(w, r)if !ok {@@ -56,6 +58,9 @@ func parseArchivedInboxFilters(w http.ResponseWriter, r *http.Request) (db.Archiif !ok {return p, false}+ if !h.requireInboxOwnerAccess(w, r, userID, p.WorkspaceID) {+ return p, false+ }p.RecipientID = parseUUID(userID)q := r.URL.Query()lists := map[string]*[]string{@@ -135,7 +140,7 @@ func archivedInboxScope(p db.ArchivedInboxFacetsParams, groupID pgtype.UUID) str}func (h *Handler) ListArchivedInboxPage(w http.ResponseWriter, r *http.Request) {- filters, ok := parseArchivedInboxFilters(w, r)+ filters, ok := h.parseArchivedInboxFilters(w, r)if !ok {return}@@ -232,7 +237,7 @@ func (h *Handler) ListArchivedInboxPage(w http.ResponseWriter, r *http.Request)}func (h *Handler) GetArchivedInboxFacets(w http.ResponseWriter, r *http.Request) {- p, ok := parseArchivedInboxFilters(w, r)+ p, ok := h.parseArchivedInboxFilters(w, r)if !ok {return}