Version: 0.9.77.dev.260505

后端:
1.阶段 6 CP4/CP5 目录收口与共享边界纯化
- 将 backend 根目录收口为 services、client、gateway、cmd、shared 五个一级目录
- 收拢 bootstrap、inits、infra/kafka、infra/outbox、conv、respond、pkg、middleware,移除根目录旧实现与空目录
- 将 utils 下沉到 services/userauth/internal/auth,将 logic 下沉到 services/schedule/core/planning
- 将迁移期 runtime 桥接实现统一收拢到 services/runtime/{conv,dao,eventsvc,model},删除 shared/legacy 与未再被 import 的旧 service 实现
- 将 gateway/shared/respond 收口为 HTTP/Gin 错误写回适配,shared/respond 仅保留共享错误语义与状态映射
- 将 HTTP IdempotencyMiddleware 与 RateLimitMiddleware 收口到 gateway/middleware
- 将 GormCachePlugin 下沉到 shared/infra/gormcache,将共享 RateLimiter 下沉到 shared/infra/ratelimit,将 agent token budget 下沉到 services/agent/shared
- 删除 InitEino 兼容壳,收缩 cmd/internal/coreinit 仅保留旧组合壳残留域初始化语义
- 更新微服务迁移计划与桌面 checklist,补齐 CP4/CP5 当前切流点、目录终态与验证结果
- 完成 go test ./...、git diff --check 与最终真实 smoke;health、register/login、task/create+get、schedule/today、task-class/list、memory/items、agent chat/meta/timeline/context-stats 全部 200,SSE 合并结果为 CP5_OK 且 [DONE] 只有 1 个
This commit is contained in:
Losita
2026-05-05 23:25:07 +08:00
parent 2a96f4c6f9
commit 3b6fca44a6
226 changed files with 731 additions and 3497 deletions

View File

@@ -7,7 +7,7 @@ import (
"net/http"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
contracts "github.com/LoveLosita/smartflow/backend/shared/contracts/activescheduler"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -11,10 +11,10 @@ import (
"sync"
"time"
gatewayagent "github.com/LoveLosita/smartflow/backend/gateway/client/agent"
"github.com/LoveLosita/smartflow/backend/model"
"github.com/LoveLosita/smartflow/backend/respond"
agentclient "github.com/LoveLosita/smartflow/backend/client/agent"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
agentsv "github.com/LoveLosita/smartflow/backend/services/agent/sv"
"github.com/LoveLosita/smartflow/backend/services/runtime/model"
agentcontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/agent"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@@ -30,7 +30,7 @@ const (
type AgentHandler struct {
svc *agentsv.AgentService
rpcClient *gatewayagent.Client
rpcClient *agentclient.Client
rpcClientMu sync.Mutex
}
@@ -48,7 +48,7 @@ func NewAgentHandler(svc *agentsv.AgentService) *AgentHandler {
// 2. agent RPC 作为 chat stream 与非 chat /agent/* 查询/命令的服务间通道;
// 3. svc 只用于 RPC 开关关闭时的迁移期 fallback当前默认可为 nil
// 4. rpcClient 为空时允许按配置懒加载,避免测试和旧装配必须提前构造 client。
func NewAgentHandlerWithRPC(svc *agentsv.AgentService, rpcClient *gatewayagent.Client) *AgentHandler {
func NewAgentHandlerWithRPC(svc *agentsv.AgentService, rpcClient *agentclient.Client) *AgentHandler {
return &AgentHandler{
svc: svc,
rpcClient: rpcClient,
@@ -302,7 +302,7 @@ func writeAgentSSEError(w io.Writer, err error) {
_ = writeSSEData(w, "[DONE]")
}
func (api *AgentHandler) getAgentRPCClient() (*gatewayagent.Client, error) {
func (api *AgentHandler) getAgentRPCClient() (*agentclient.Client, error) {
if api == nil {
return nil, errors.New("agent handler is not initialized")
}
@@ -314,7 +314,7 @@ func (api *AgentHandler) getAgentRPCClient() (*gatewayagent.Client, error) {
return api.rpcClient, nil
}
client, err := gatewayagent.NewClient(gatewayagent.ClientConfig{
client, err := agentclient.NewClient(agentclient.ClientConfig{
Endpoints: viper.GetStringSlice("agent.rpc.endpoints"),
Target: viper.GetString("agent.rpc.target"),
Timeout: viper.GetDuration("agent.rpc.timeout"),

View File

@@ -9,7 +9,7 @@ import (
"net/http"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
coursecontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/course"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
memorycontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/memory"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
contracts "github.com/LoveLosita/smartflow/backend/shared/contracts/notification"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -6,7 +6,7 @@ import (
"strconv"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
schedulecontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/schedule"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -6,7 +6,7 @@ import (
"strconv"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
taskclasscontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/taskclass"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"time"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
taskcontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/task"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -7,7 +7,7 @@ import (
"time"
gatewaymiddleware "github.com/LoveLosita/smartflow/backend/gateway/middleware"
"github.com/LoveLosita/smartflow/backend/respond"
"github.com/LoveLosita/smartflow/backend/gateway/shared/respond"
contracts "github.com/LoveLosita/smartflow/backend/shared/contracts/userauth"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"

View File

@@ -2,8 +2,8 @@ package userauthapi
import (
gatewaymiddleware "github.com/LoveLosita/smartflow/backend/gateway/middleware"
rootmiddleware "github.com/LoveLosita/smartflow/backend/middleware"
"github.com/LoveLosita/smartflow/backend/pkg"
rootmiddleware "github.com/LoveLosita/smartflow/backend/gateway/middleware"
ratelimit "github.com/LoveLosita/smartflow/backend/shared/infra/ratelimit"
"github.com/LoveLosita/smartflow/backend/shared/ports"
"github.com/gin-gonic/gin"
)
@@ -13,7 +13,7 @@ import (
// 1. 只注册 /user 下的边缘路由,不关心其它业务域路由;
// 2. 登录、注册、刷新 token 只做请求转发;登出需要先经过 access token 边缘鉴权;
// 3. 限流仍复用当前通用中间件,后续若 gateway 独立成包,可再整体下沉。
func RegisterRoutes(apiGroup *gin.RouterGroup, handler *UserHandler, authClient ports.AccessTokenValidator, limiter *pkg.RateLimiter) {
func RegisterRoutes(apiGroup *gin.RouterGroup, handler *UserHandler, authClient ports.AccessTokenValidator, limiter *ratelimit.RateLimiter) {
if apiGroup == nil || handler == nil {
return
}