oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package taskplan
2
3// ValidatePlaybook retains publication safeguards even for a saved investigation.
4// Investigation execution is projected separately, ending at its person checkpoint.
5func ValidatePlaybook(kind Kind, steps []Step) error {
6 if kind == Recommendation {
7 return ErrInvalid
8 }
9 p := Plan{Kind: kind, ProjectID: 1, Steps: steps}
10 if kind == Investigation {
11 p.Kind = Feature
12 research := 0
13 for _, s := range steps {
14 switch s.Action {
15 case "scope", "investigate", "recommend":
16 research++
17 case "review", "checks", "person":
18 default:
19 return ErrInvalid
20 }
21 }
22 if research == 0 {
23 return ErrInvalid
24 }
25 }
26 if err := Validate(p); err != nil {
27 return err
28 }
29 n := len(steps)
30 if n < 3 {
31 return ErrInvalid
32 }
33 end := n - 1
34 if end > 0 && steps[end-1].Action == "publish" {
35 end--
36 }
37 if end < 2 || steps[end-2].Action != "review" || steps[end-1].Action != "checks" {
38 return ErrInvalid
39 }
40 if kind == Investigation && Validate(Plan{Kind: kind, ProjectID: 1, Steps: PlaybookSteps(kind, steps)}) != nil {
41 return ErrInvalid
42 }
43 return nil
44}
45func PlaybookSteps(kind Kind, steps []Step) []Step {
46 out := []Step{}
47 for _, s := range steps {
48 if kind == Investigation && (s.Action == "review" || s.Action == "checks") {
49 continue
50 }
51 s.DependsOn = append([]string(nil), s.DependsOn...)
52 out = append(out, s)
53 }
54 return Normalize(Plan{Kind: kind, Steps: out}).Steps
55}
56