- Server no longer mirrors app.Runtime services (gov/svc/pwSvc/...): 574 call sites now use accessors in runtime_accessors.go - backgroundLoop (mutex+sync.Once) stops sweeper/publisher/reminder/wsGC goroutines race-free (baseline44161d2areproduced DATA RACE; now green under -race) - goose 00071 duplicate (dialogue merge1da17a28brought two 00071): context-conflict-adjudications renumbered to 00072; dev DB applied only through 00070 so zero data migration - task_finalize tests build minimal app.Runtime; test injection via serverTestOverrides + setOverride* (explicit-nil markers for fail-closed cases)
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"chat-agent-system/internal/docgov"
|
|
"chat-agent-system/internal/events"
|
|
"chat-agent-system/internal/notification"
|
|
)
|
|
|
|
func (s *Server) registerWorkflowApprovalHook() {
|
|
// Durable workflow_advance is the unique writer. Keep the method for one
|
|
// rollback window; do not register AddOnApprovedHook in production.
|
|
return
|
|
}
|
|
|
|
func (s *Server) onWorkflowDocumentApproved(ctx context.Context, doc *docgov.DocumentRecord) {
|
|
if s.rt != nil && s.rt.WriterLive(ctx, events.ConsumerWorkflowAdvance) {
|
|
return
|
|
}
|
|
if doc == nil || doc.TaskKey == "" || doc.ProjectID <= 0 || s.instSvc() == nil {
|
|
return
|
|
}
|
|
|
|
result, err := s.instSvc().HandleDocumentApproved(ctx, doc.ProjectID, doc.TaskKey)
|
|
if err != nil || result == nil || !result.StageReady {
|
|
return
|
|
}
|
|
if s.notifySvc() == nil || !s.notifySvc().Available() {
|
|
return
|
|
}
|
|
|
|
project, err := s.pwSvc().GetProject(ctx, doc.ProjectID, 0)
|
|
if err != nil || project == nil || project.CreatorUserID <= 0 {
|
|
return
|
|
}
|
|
|
|
_, _ = s.notifySvc().EmitStageReadyToAdvance(ctx, project.CreatorUserID, notification.StageReadyPayload{
|
|
ProjectID: doc.ProjectID,
|
|
WorkflowInstanceID: result.InstanceID,
|
|
StageInstanceID: result.StageInstanceID,
|
|
StageKey: result.StageKey,
|
|
StageName: result.StageName,
|
|
ConfigRevision: result.ConfigRevision,
|
|
RequiredDocCount: result.RequiredDocCount,
|
|
ApprovedDocCount: result.ApprovedDocCount,
|
|
})
|
|
}
|