Files
weichen 4e0e6a1418 feat(notification): digest aggregates, supplement-impact batch, and free-collab hooks
Add notification digests with ON CONFLICT DO UPDATE, migrations 00068-00070,
supplementimpact module (analyze → confirm → claim-aware split), and wire
coordinator/mutate hooks plus proposal_required digests.
2026-09-24 11:44:20 +00:00

51 lines
1.7 KiB
Go

package bizdev
import (
"context"
"fmt"
"chat-agent-system/internal/docgov"
)
// TaskExecutor is the ForceDirectEdit execution surface used by AfterProposalApproved.
type TaskExecutor interface {
ExecuteTask(ctx context.Context, req TaskRunRequest) (*TaskRunResult, error)
}
// AfterProposalApproved starts a ForceDirectEdit task run as the author after a
// proposal reaches approved_by_author. Finalize already calls MarkProposalApplied
// when FindApprovedProposal succeeds under ForceDirectEdit.
//
// Server composition (non-author worktree) should call this after
// DecideModificationProposal(approve=true) succeeds; pass a base TaskRunRequest
// with TaskKey/DocID/project fields filled from the document context.
func AfterProposalApproved(ctx context.Context, exec TaskExecutor, prop *docgov.ChangeProposal, authorID int64, base TaskRunRequest) (*TaskRunResult, error) {
if exec == nil {
return nil, fmt.Errorf("bizdev: AfterProposalApproved requires executor")
}
if prop == nil {
return nil, fmt.Errorf("bizdev: AfterProposalApproved requires proposal")
}
if authorID <= 0 {
return nil, fmt.Errorf("bizdev: AfterProposalApproved requires author id")
}
req := base
req.ForceDirectEdit = true
req.UserID = authorID
if req.AuthorID == 0 {
req.AuthorID = authorID
}
if req.DocID == "" {
req.DocID = prop.DocID
}
if req.ProjectID == 0 {
req.ProjectID = prop.ProjectID
}
return exec.ExecuteTask(ctx, req)
}
// AfterProposalApproved is the Service convenience wrapper.
func (s *Service) AfterProposalApproved(ctx context.Context, prop *docgov.ChangeProposal, authorID int64, base TaskRunRequest) (*TaskRunResult, error) {
return AfterProposalApproved(ctx, s, prop, authorID, base)
}