feat(bizdev): 贯通跨阶段事实黑板自动传承与里程碑决策记录

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WeiCHEN
2026-09-13 02:50:19 +00:00
committed by weichen
co-authored by Cursor
parent c290f3104b
commit 429179e472
+37
View File
@@ -385,6 +385,16 @@ func (s *Service) executeStageInternal(ctx context.Context, req StageRunRequest)
// 3. 汇总当前阶段累积的事实与前序文档
currentFields := make(map[string]string)
// 若存在项目协同管理器,优先载入已沉淀的项目事实与黑板
if s.ctxMgr != nil && req.ProjectID > 0 {
if projCtx, err := s.ctxMgr.GetProjectContext(ctx, req.ProjectID); err == nil && projCtx != nil {
for k, v := range projCtx.BlackboardFacts {
currentFields[k] = v
}
}
}
if req.Fields != nil {
for k, v := range req.Fields {
currentFields[k] = v
@@ -531,6 +541,33 @@ func (s *Service) executeStageInternal(ctx context.Context, req StageRunRequest)
}
}
// 将本阶段累积沉淀的事实回填到 ContextManager,供下一阶段或后续对话读取
if s.ctxMgr != nil && req.ProjectID > 0 {
_ = s.ctxMgr.UpdateProjectBlackboard(ctx, req.ProjectID, currentFields)
_ = s.ctxMgr.UpdateProjectStage(ctx, req.ProjectID, string(req.Stage))
authorName := req.AuthorName
if authorName == "" {
authorName = "系统协调员"
}
_, _ = s.ctxMgr.RecordActivity(
ctx,
req.ProjectID,
req.UserID,
authorName,
"stage_advance",
fmt.Sprintf("阶段跃迁至【%s】", targetMeta.Title),
map[string]any{
"stage": string(req.Stage),
"duration_ms": time.Since(start).Milliseconds(),
"artifacts": len(executedArtifacts),
"device_type": req.DeviceType,
"target_market": req.TargetMarket,
},
1.0,
true, // 里程碑决策,豁免衰减
)
}
if streamer != nil {
streamer.EmitPhase("stage_completed", fmt.Sprintf("商务成熟度阶段【%s】全部任务协同推演完成!", req.Stage), "coordinator", len(targetMeta.Tasks), len(targetMeta.Tasks), 100)
if stageBrief != nil {