Published manifests now use bd_/pm_/tm_/sw_ prefixes so workflows cannot share a doc id. Frozen instances keep the old keys; lookup, templates, and duty checks treat the two names as the same task. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"chat-agent-system/internal/projectinstance"
|
|
"chat-agent-system/internal/workflowdef"
|
|
)
|
|
|
|
// projectInstanceDutyAdapter 将活跃工作流实例的逐文档职责投影为 bizdev 窄接口,
|
|
// 避免 bizdev 导入 projectinstance。
|
|
type projectInstanceDutyAdapter struct {
|
|
inst *projectinstance.Service
|
|
}
|
|
|
|
func (a *projectInstanceDutyAdapter) ResolveGovernedDuty(ctx context.Context, projectID int64, taskKey string) (author, reviewer, approver int64, dutyPolicy string, governed bool, err error) {
|
|
if a == nil || a.inst == nil || projectID <= 0 {
|
|
return 0, 0, 0, "", false, nil
|
|
}
|
|
taskKey = strings.TrimSpace(taskKey)
|
|
if taskKey == "" {
|
|
return 0, 0, 0, "", false, nil
|
|
}
|
|
detail, _, derr := a.inst.GetLiveInstanceDetail(ctx, projectID)
|
|
if derr != nil || detail == nil {
|
|
// 无活跃实例(规划中/legacy)→ 不受治理,非错误
|
|
return 0, 0, 0, "", false, nil
|
|
}
|
|
for _, st := range detail.Instance.ConfigSnapshot.Stages {
|
|
for _, dt := range st.DocTasks {
|
|
if !workflowdef.SameTaskKey(dt.TaskKey, taskKey) || !dt.Enabled {
|
|
continue
|
|
}
|
|
mode, effective, isAuthorOnly := projectinstance.ResolveDocTaskDuty(dt)
|
|
if mode != projectinstance.DutyModeFull {
|
|
return 0, 0, 0, "", false, nil
|
|
}
|
|
policy := projectinstance.DutyPolicySeparated
|
|
if isAuthorOnly {
|
|
policy = projectinstance.DutyPolicyAuthorOnly
|
|
}
|
|
return effective.AuthorUserID, effective.ReviewerUserID, effective.ApproverUserID, policy, true, nil
|
|
}
|
|
}
|
|
return 0, 0, 0, "", false, nil
|
|
}
|