fix(land): 适配 dev 现行结构 — gov()/authorizer() 访问器、去 app/docnotify stream 依赖(arch 基线)、测试 stub 重名

This commit is contained in:
weichen
2026-09-25 20:17:20 +00:00
parent 05b822d9c0
commit 6c815b2958
4 changed files with 6 additions and 16 deletions
+1 -11
View File
@@ -8,7 +8,6 @@ import (
"chat-agent-system/internal/ctxmgr" "chat-agent-system/internal/ctxmgr"
"chat-agent-system/internal/docgov" "chat-agent-system/internal/docgov"
"chat-agent-system/internal/notification" "chat-agent-system/internal/notification"
"chat-agent-system/internal/stream"
) )
// LifecycleAction identifies a governance transition for routing. // LifecycleAction identifies a governance transition for routing.
@@ -52,12 +51,11 @@ func RecipientForDocEvent(doc *docgov.DocumentRecord, eventType string) int64 {
return 0 return 0
} }
// EmitLifecycleParams carries optional chat/SSE side channels. // EmitLifecycleParams carries optional chat side channels.
type EmitLifecycleParams struct { type EmitLifecycleParams struct {
Notify notificationEmitter Notify notificationEmitter
Digest digestUpserter Digest digestUpserter
Chat *ctxmgr.ContextManager Chat *ctxmgr.ContextManager
Streamer *stream.Streamer
Action LifecycleAction Action LifecycleAction
Doc *docgov.DocumentRecord Doc *docgov.DocumentRecord
ActorID int64 ActorID int64
@@ -105,14 +103,6 @@ func EmitLifecycle(ctx context.Context, p EmitLifecycleParams) {
"doc_id": p.Doc.DocID, "action": string(p.Action), "event": eventType, "doc_id": p.Doc.DocID, "action": string(p.Action), "event": eventType,
}) })
} }
if p.Streamer != nil {
p.Streamer.EmitGovernance(stream.GovernancePayload{
DocID: p.Doc.DocID, Action: string(p.Action), CurrentState: string(p.Doc.CurrentState),
IsLocked: p.Doc.IsLocked, AuthorClaimed: p.Doc.AuthorClaimed,
NotificationTitle: title, NotificationMsg: body,
})
}
} }
func digestKindForEvent(eventType string) string { func digestKindForEvent(eventType string) string {
+2 -2
View File
@@ -10,14 +10,14 @@ import (
"chat-agent-system/internal/intent" "chat-agent-system/internal/intent"
) )
type stubDocResolver struct { type stubDocResolverDialogue struct {
doc *coordinator.ResolvedDoc doc *coordinator.ResolvedDoc
ok bool ok bool
candidates []string candidates []string
err error err error
} }
func (s *stubDocResolver) ResolveDoc(context.Context, int64, string, string) (*coordinator.ResolvedDoc, bool, []string, error) { func (s *stubDocResolverDialogue) ResolveDoc(context.Context, int64, string, string) (*coordinator.ResolvedDoc, bool, []string, error) {
return s.doc, s.ok, s.candidates, s.err return s.doc, s.ok, s.candidates, s.err
} }
+1 -1
View File
@@ -386,7 +386,7 @@ func (s *Server) handleDocGovAddComment(w http.ResponseWriter, r *http.Request)
// handleDocGovResolveComment marks a comment resolved or reopens it. // handleDocGovResolveComment marks a comment resolved or reopens it.
func (s *Server) handleDocGovResolveComment(w http.ResponseWriter, r *http.Request) { func (s *Server) handleDocGovResolveComment(w http.ResponseWriter, r *http.Request) {
if s.gov == nil { if s.gov() == nil {
writeSafeError(w, r, http.StatusServiceUnavailable, "docgov engine not initialized") writeSafeError(w, r, http.StatusServiceUnavailable, "docgov engine not initialized")
return return
} }
+2 -2
View File
@@ -265,7 +265,7 @@ func (s *Server) callerMayRequestReopen(r *http.Request, projectID, userID int64
func (s *Server) callerMayApproveReopen(ctx context.Context, projectID, userID int64, creator bool, req traceimpact.ReopenRequest) bool { func (s *Server) callerMayApproveReopen(ctx context.Context, projectID, userID int64, creator bool, req traceimpact.ReopenRequest) bool {
hasActiveApprover := false hasActiveApprover := false
userIsApprover := false userIsApprover := false
if s.gov != nil { if s.gov() != nil {
for _, taskKey := range req.DocTasks { for _, taskKey := range req.DocTasks {
docID := fmt.Sprintf("doc_proj%d_%s", projectID, taskKey) docID := fmt.Sprintf("doc_proj%d_%s", projectID, taskKey)
doc, err := s.gov().GetDocument(ctx, docID) doc, err := s.gov().GetDocument(ctx, docID)
@@ -291,7 +291,7 @@ func (s *Server) callerMayApproveReopen(ctx context.Context, projectID, userID i
} }
func (s *Server) projectMemberActive(ctx context.Context, projectID, userID int64) bool { func (s *Server) projectMemberActive(ctx context.Context, projectID, userID int64) bool {
if s.authorizer == nil || userID <= 0 { if s.authorizer() == nil || userID <= 0 {
return userID > 0 return userID > 0
} }
rec, err := s.authorizer().GetProjectMember(ctx, projectID, userID) rec, err := s.authorizer().GetProjectMember(ctx, projectID, userID)