【架构优化】合并 catalog/assistant handler 中重复的资产引用查找为包级 helper
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 15/100
Línea de trabajo
The three duplicated lookups are the agentNamesReferencing, sandboxNamesReferencing and workflowNamesReferencingSandbox methods on catalogHandlers in internal/httpapi/catalog.go and assistantHandlers in internal/httpapi/assistant_approval.go. Pull request #445 is already open against this issue, so check it before starting. Done means the package-level helpers in asset_references.go are used by both handlers, the new asset_references_test.go passes, and go test ./internal/httpapi/ is green.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
现状问题
internal/httpapi/catalog.go(catalogHandlers)与 internal/httpapi/assistant_approval.go(assistantHandlers)各自定义了一份逐字相同的资产引用查找方法:
agentNamesReferencing(kind, id):列出引用某规则/技能的角色名sandboxNamesReferencing(kind, id):列出引用某 Dockerfile/环境脚本的沙箱名workflowNamesReferencingSandbox(id):列出引用某沙箱的流程名
两份实现共约 45 行重复,只依赖 *repo.Store 的只读查询,与各自 handler 的其它状态无关。目录删除校验(catalog)和助手删除审批预警(assistant)判断"是否仍被引用"的口径本应一致,重复实现容易在后续修改时只改一边而出现偏差。
重构方案
- 新建包级 helper 文件
internal/httpapi/asset_references.go,提供三个无 receiver 的函数agentNamesReferencing(st *repo.Store, kind, id)、sandboxNamesReferencing(st, kind, id)、workflowNamesReferencingSandbox(st, id),实现与现有代码逐行一致(符合 AGENTS.md「纯共享的包级 helper 可以放独立 helper 文件」)。 - 删除两个 handler 上的重复方法,调用处改为传
h.repo。 - 现有测试中对旧方法的调用同步改为调用包级函数。
影响范围
仅 internal/httpapi 包内部未导出函数;不涉及 HTTP 接口、错误文案、返回值或排序,行为不变。
验证方式
- 新增
asset_references_test.go覆盖三个函数(重复引用只计一次、kind 区分、未引用返回空)。 gofmt、go vet ./internal/httpapi/、go test ./internal/httpapi/通过(本机缺 Chromium 的浏览器用例除外,与 main 一致)。
- Lenguaje dominante
- Go
- Estrellas
- 141
- Forks
- 28
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 113
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Tencent/LoopForge
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
[Bug]: 官方镜像未安装 wecom-cli,企业微信通知报「通知服务未安装 wecom-cli」Posiblemente ocupada @newexploreor la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Tencent/LoopForge#156 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
【架构优化】合并 gitwork/workbranch.go 中 push/pull 重复的默认提交身份注入为 withFallbackIdentityPosiblemente ocupada @fx-kurumi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 40/100
Los mantenedores suelen responder en 1 día
-
【架构优化】从 runtime.installNPMCLI 中拆出 npm 参数拼装 npmCLIInstallArgs 与安装结果启用 activateNPMStagePosiblemente ocupada @fx-kurumi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
Todos los issues de Tencent/LoopForge
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
bazel-contrib/rules_go#4784 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Уязвимые компоненты в GoAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
POSIdev-community/aictl#40 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
nebari-dev/nebari-infrastructure-core#774 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
oracle/terraform-provider-oci#2662 ·
-
[BUG]: A pre-hashed ACL password in uppercase hex fails ACL LOAD and crash-loops restarted podsAbiertobug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
valkey-io/valkey-operator#644 ·
Los mantenedores suelen responder en 3 días