docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批: 已推库 16 个文件 + 本批剩余文件)。 校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0); 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
1 parent
91e8d7a029
commit
074ffc4ebf
73 files changed
+2529
-2529
No files matched your search
@@ -11,22 +11,22 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/memory"
|
||||
)
|
||||
|
||||
// Admin memory + knowledge-base write endpoints (owner-only, audited). The memory
|
||||
// add writes a real item into the memory store (owner-private, safe), and the RAG
|
||||
// index imports a document into the project index so it becomes searchable. Both
|
||||
// degrade to a clear 501 when their backing store is not wired.
|
||||
// 管理侧记忆 + 知识库写端点(仅 owner,带审计)。添加记忆
|
||||
// 会把真实条目写入记忆存储(owner 私有,安全),而 RAG 索引
|
||||
// 把文档导入项目索引使其可被检索。二者在各自
|
||||
// 后端存储未接线时都退化为明确的 501。
|
||||
|
||||
// memoryAddRequest is the POST /api/v1/admin/memories body.
|
||||
// memoryAddRequest 是 POST /api/v1/admin/memories 的请求体。
|
||||
type memoryAddRequest struct {
|
||||
PersonaID string `json:"personaId"`
|
||||
Content string `json:"content"`
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
// adminAddMemory writes a single memory item for the owner. It is the manual
|
||||
// "添加记忆" path: the item is scoped to the persona (default), so it behaves like
|
||||
// the "记住 X" path the loop already writes. Scope may be omitted (default
|
||||
// persona) or one of user|persona|project; an invalid non-empty scope is rejected.
|
||||
// adminAddMemory 为主人写入单条记忆。它是手动的
|
||||
// 「添加记忆」路径:条目默认作用于 persona,因此行为与
|
||||
// loop 已在写的「记住 X」路径一致。Scope 可省略(默认
|
||||
// persona),或为 user|persona|project 之一;非法非空 scope 会被拒绝。
|
||||
func (s *Server) adminAddMemory(w http.ResponseWriter, r *http.Request) {
|
||||
var req memoryAddRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
@@ -70,7 +70,7 @@ func (s *Server) adminAddMemory(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusCreated, map[string]any{"id": stored.ID, "scope": string(stored.Scope), "text": stored.Content})
|
||||
}
|
||||
|
||||
// isValidMemoryScope reports whether raw is one of the defined memory scopes.
|
||||
// isValidMemoryScope 报告 raw 是否是已定义的记忆作用域之一。
|
||||
func isValidMemoryScope(raw string) bool {
|
||||
switch memory.Scope(strings.TrimSpace(raw)) {
|
||||
case memory.ScopeUser, memory.ScopePersona, memory.ScopeProject:
|
||||
@@ -80,16 +80,16 @@ func isValidMemoryScope(raw string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// ragIndexRequest is the POST /api/v1/admin/rag body.
|
||||
// ragIndexRequest 是 POST /api/v1/admin/rag 的请求体。
|
||||
type ragIndexRequest struct {
|
||||
Name string `json:"name"`
|
||||
Desc string `json:"desc"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// adminIndexRag imports one knowledge document: it hands the name/description and
|
||||
// content to the knowledge store, which chunks it and indexes it into the project
|
||||
// index so the document becomes keyword/searchable. It is the admin "导入文档" path.
|
||||
// adminIndexRag 导入一份知识文档:它把 name/description 与
|
||||
// content 交给知识存储,后者切分它并索引进项目
|
||||
// 索引,使文档可被关键词检索。它是管理侧的「导入文档」路径。
|
||||
func (s *Server) adminIndexRag(w http.ResponseWriter, r *http.Request) {
|
||||
var req ragIndexRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
@@ -127,15 +127,15 @@ func (s *Server) adminIndexRag(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusCreated, map[string]any{"name": name})
|
||||
}
|
||||
|
||||
// ragDeleteRequest is the POST /api/v1/admin/rag/delete body.
|
||||
// ragDeleteRequest 是 POST /api/v1/admin/rag/delete 的请求体。
|
||||
type ragDeleteRequest struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// adminDeleteRag removes a knowledge document by id: the store deletes the
|
||||
// project-index entry and cascades its chapters. A missing document is answered
|
||||
// with 404, a store that cannot delete with a clear 501, and any other failure
|
||||
// with 500 — never a fabricated success. The route is owner-gated and audited.
|
||||
// adminDeleteRag 按 id 移除一份知识文档:存储删除
|
||||
// 项目索引条目并级联其章节。文档缺失时返回 404,
|
||||
// 存储无法删除时返回明确的 501,其他失败
|
||||
// 返回 500 —— 绝不编造成功。该路由受 owner 门控且带审计。
|
||||
func (s *Server) adminDeleteRag(w http.ResponseWriter, r *http.Request) {
|
||||
if s.rag == nil {
|
||||
s.auditClaims(r, "rag.delete", "error")
|
||||
|
||||
Reference in new issue
Block a user