Add the owner field to tenant-scoped domain contracts

Details (original message):
Add the owner field to tenant-scoped domain contracts (project, conversation, run, artifact, knowledge)
This commit is contained in:
weichen
2026-09-30 02:39:50 +00:00
parent 95294268d8
commit 061eef5214
3 changed files with 12 additions and 5 deletions
+1
View File
@@ -99,6 +99,7 @@ type ParserDesc struct {
// KnowledgeDoc 是检索语料的一条文档(来自 ingest 或插件知识库,带来源标记)。
type KnowledgeDoc struct {
ID ID `json:"id"`
Owner ID `json:"owner,omitempty"` // 空 = 共享(插件级)知识
ProjectID ID `json:"projectId,omitempty"` // 空 = 插件级知识库
Source string `json:"source"` // upload | artifact | plugin:<id>
Title string `json:"title"`
+6
View File
@@ -14,8 +14,11 @@ type ID = string
// ---- 项目与会话 ----
// Owner 是租户标识(多租户主线,设计 D5/D16):空串 = 单租户默认(嵌入式档/
// 未启用认证时的隐式 owner)。API 层强制 owner 过滤,跨租户访问一律 NotFound。
type Project struct {
ID ID `json:"id"`
Owner ID `json:"owner,omitempty"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
@@ -25,6 +28,7 @@ type Project struct {
type Conversation struct {
ID ID `json:"id"`
ProjectID ID `json:"projectId"`
Owner ID `json:"owner,omitempty"` // 冗余自项目,查询过滤用
Title string `json:"title"`
ProfileID ID `json:"profileId,omitempty"` // 空为默认画像
CreatedAt time.Time `json:"createdAt"`
@@ -157,6 +161,7 @@ type Run struct {
ParentRunID ID `json:"parentRunId,omitempty"`
ConversationID ID `json:"conversationId"`
ProjectID ID `json:"projectId"`
Owner ID `json:"owner,omitempty"` // 冗余自会话
Kind RunKind `json:"kind"`
ProfileID ID `json:"profileId,omitempty"`
Status RunStatus `json:"status"`
@@ -181,6 +186,7 @@ type Usage struct {
type Artifact struct {
ID ID `json:"id"`
ProjectID ID `json:"projectId"`
Owner ID `json:"owner,omitempty"` // 冗余自项目
Name string `json:"name"`
Kind string `json:"kind"`
MIME string `json:"mime,omitempty"`
+5 -5
View File
@@ -7,12 +7,12 @@ export type ID = string;
// ---- 领域模型 ----
export interface Project {
id: ID; name: string; createdAt: string; updatedAt: string;
id: ID; owner?: ID; name: string; createdAt: string; updatedAt: string;
settings?: Record<string, unknown>;
}
export interface Conversation {
id: ID; projectId: ID; title: string; profileId?: ID;
id: ID; projectId: ID; owner?: ID; title: string; profileId?: ID;
createdAt: string; updatedAt: string;
}
@@ -52,14 +52,14 @@ export interface Usage {
}
export interface Run {
id: ID; parentRunId?: ID; conversationId: ID; projectId: ID;
id: ID; parentRunId?: ID; conversationId: ID; projectId: ID; owner?: ID;
kind: RunKind; profileId?: ID; status: RunStatus; phase?: RunPhase;
agentName?: string; createdAt: string; endedAt?: string;
usage?: Usage; error?: { code: string; message: string };
}
export interface Artifact {
id: ID; projectId: ID; name: string; kind: string; mime?: string;
id: ID; projectId: ID; owner?: ID; name: string; kind: string; mime?: string;
size: number; sourceRun?: ID; createdAt: string; updatedAt: string;
}
@@ -202,7 +202,7 @@ export interface ParsedDocument {
}
export interface RetrievalHit {
doc: { id: ID; projectId?: ID; source: string; title: string; ref?: string; chunk: string; createdAt: string };
doc: { id: ID; owner?: ID; projectId?: ID; source: string; title: string; ref?: string; chunk: string; createdAt: string };
score: number; kind: 'fulltext' | 'vector' | 'plugin';
}