Replace implemented column with CMMI maturity level

Drop the boolean implemented/not-implemented state in favor of a
mandatory CMMI maturity level enum (NONE, INITIAL, MANAGED, DEFINED,
QUANTITATIVELY_MANAGED, OPTIMIZING) stored as a Postgres enum type.

The migration backfills existing rows (NOT_IMPLEMENTED → NONE,
IMPLEMENTED → INITIAL), makes the column NOT NULL, and drops the old
implemented column and its enum type.

- maturityLevel is required on CreateControlInput and non-nullable (!)
  in the GraphQL schema
- CLI displays human-readable CMMI labels instead of raw enum tokens
- SOA table and published document use a single Maturity column in
  place of the old Implemented + Maturity columns
- Remove ControlImplementationState type and all implemented references
  across backend, frontend, CLI, MCP, n8n, and E2E tests

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-04-20 20:48:23 +02:00
parent da91afc2a7
commit e1148f812e
32 changed files with 271 additions and 586 deletions

View File

@@ -33,7 +33,6 @@ mutation($input: CreateControlInput!) {
name
description
bestPractice
implemented
notImplementedJustification
maturityLevel
}
@@ -60,9 +59,8 @@ type createResponse struct {
Name string `json:"name"`
Description *string `json:"description"`
BestPractice bool `json:"bestPractice"`
Implemented string `json:"implemented"`
NotImplementedJustification *string `json:"notImplementedJustification"`
MaturityLevel *string `json:"maturityLevel"`
MaturityLevel string `json:"maturityLevel"`
} `json:"node"`
} `json:"controlEdge"`
} `json:"createControl"`
@@ -75,16 +73,15 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
flagName string
flagDescription string
flagBestPractice bool
flagNotImplemented bool
flagNotImplementedJustification string
flagMaturityLevel string
flagNotImplementedJustification string
)
cmd := &cobra.Command{
Use: "create",
Short: "Create a new control",
Example: ` # Create a control
prb control create --framework FW_ID --section-title "A.5" --name "Information security policies"`,
prb control create --framework FW_ID --section-title "A.5" --name "Information security policies" --maturity-level INITIAL`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
@@ -105,34 +102,26 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
cmdutil.TokenRefreshOption(cfg, host, hc),
)
implemented := "IMPLEMENTED"
if flagNotImplemented {
implemented = "NOT_IMPLEMENTED"
if err := cmdutil.ValidateEnum("maturity-level", flagMaturityLevel, maturityLevelValues); err != nil {
return err
}
input := map[string]any{
"frameworkId": flagFramework,
"sectionTitle": flagSectionTitle,
"name": flagName,
"bestPractice": flagBestPractice,
"implemented": implemented,
"frameworkId": flagFramework,
"sectionTitle": flagSectionTitle,
"name": flagName,
"bestPractice": flagBestPractice,
"maturityLevel": flagMaturityLevel,
}
if flagDescription != "" {
input["description"] = flagDescription
}
if flagNotImplemented && flagNotImplementedJustification != "" {
if flagMaturityLevel == "NONE" && flagNotImplementedJustification != "" {
input["notImplementedJustification"] = flagNotImplementedJustification
}
if flagMaturityLevel != "" {
if err := cmdutil.ValidateEnum("maturity-level", flagMaturityLevel, maturityLevelValues); err != nil {
return err
}
input["maturityLevel"] = flagMaturityLevel
}
data, err := client.Do(
createMutation,
map[string]any{"input": input},
@@ -163,9 +152,8 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
cmd.Flags().StringVar(&flagName, "name", "", "Control name (required)")
cmd.Flags().StringVar(&flagDescription, "description", "", "Control description")
cmd.Flags().BoolVar(&flagBestPractice, "best-practice", false, "Mark as best practice")
cmd.Flags().BoolVar(&flagNotImplemented, "not-implemented", false, "Mark as not implemented")
cmd.Flags().StringVar(&flagNotImplementedJustification, "not-implemented-justification", "", "Justification for non-implementation")
cmd.Flags().StringVar(&flagMaturityLevel, "maturity-level", "", "CMMI maturity level (NONE, INITIAL, MANAGED, DEFINED, QUANTITATIVELY_MANAGED, OPTIMIZING)")
cmd.Flags().StringVar(&flagMaturityLevel, "maturity-level", "INITIAL", "CMMI maturity level (NONE, INITIAL, MANAGED, DEFINED, QUANTITATIVELY_MANAGED, OPTIMIZING)")
cmd.Flags().StringVar(&flagNotImplementedJustification, "not-implemented-justification", "", "Justification when maturity level is NONE")
_ = cmd.MarkFlagRequired("framework")
_ = cmd.MarkFlagRequired("section-title")

View File

@@ -21,6 +21,8 @@ import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/docgen"
)
const listQuery = `
@@ -37,7 +39,6 @@ query($id: ID!, $first: Int, $after: CursorKey, $orderBy: ControlOrder, $filter:
name
description
bestPractice
implemented
maturityLevel
}
}
@@ -57,8 +58,7 @@ type control struct {
Name string `json:"name"`
Description *string `json:"description"`
BestPractice bool `json:"bestPractice"`
Implemented string `json:"implemented"`
MaturityLevel *string `json:"maturityLevel"`
MaturityLevel string `json:"maturityLevel"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
@@ -167,16 +167,12 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
if c.BestPractice {
bp = "Yes"
}
maturity := "-"
if c.MaturityLevel != nil {
maturity = *c.MaturityLevel
}
rows = append(rows, []string{
c.ID,
c.SectionTitle,
c.Name,
bp,
maturity,
docgen.MaturityLabel(coredata.ControlMaturityLevel(c.MaturityLevel)),
})
}

View File

@@ -32,7 +32,6 @@ mutation($input: UpdateControlInput!) {
name
description
bestPractice
implemented
notImplementedJustification
maturityLevel
}
@@ -48,9 +47,8 @@ type updateResponse struct {
Name string `json:"name"`
Description *string `json:"description"`
BestPractice bool `json:"bestPractice"`
Implemented string `json:"implemented"`
NotImplementedJustification *string `json:"notImplementedJustification"`
MaturityLevel *string `json:"maturityLevel"`
MaturityLevel string `json:"maturityLevel"`
} `json:"control"`
} `json:"updateControl"`
}
@@ -70,9 +68,8 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
flagName string
flagDescription string
flagBestPractice bool
flagNotImplemented bool
flagNotImplementedJustification string
flagMaturityLevel string
flagNotImplementedJustification string
)
cmd := &cobra.Command{
@@ -118,12 +115,11 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
if cmd.Flags().Changed("best-practice") {
input["bestPractice"] = flagBestPractice
}
if cmd.Flags().Changed("not-implemented") {
if flagNotImplemented {
input["implemented"] = "NOT_IMPLEMENTED"
} else {
input["implemented"] = "IMPLEMENTED"
if cmd.Flags().Changed("maturity-level") {
if err := cmdutil.ValidateEnum("maturity-level", flagMaturityLevel, maturityLevelValues); err != nil {
return err
}
input["maturityLevel"] = flagMaturityLevel
}
if cmd.Flags().Changed("not-implemented-justification") {
if flagNotImplementedJustification == "" {
@@ -132,16 +128,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
input["notImplementedJustification"] = flagNotImplementedJustification
}
}
if cmd.Flags().Changed("maturity-level") {
if flagMaturityLevel == "" {
input["maturityLevel"] = nil
} else {
if err := cmdutil.ValidateEnum("maturity-level", flagMaturityLevel, maturityLevelValues); err != nil {
return err
}
input["maturityLevel"] = flagMaturityLevel
}
}
if len(input) == 1 {
return fmt.Errorf("at least one field must be specified for update")
@@ -176,9 +162,8 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
cmd.Flags().StringVar(&flagName, "name", "", "Control name")
cmd.Flags().StringVar(&flagDescription, "description", "", "Control description")
cmd.Flags().BoolVar(&flagBestPractice, "best-practice", false, "Mark as best practice")
cmd.Flags().BoolVar(&flagNotImplemented, "not-implemented", false, "Mark as not implemented")
cmd.Flags().StringVar(&flagNotImplementedJustification, "not-implemented-justification", "", "Justification for non-implementation")
cmd.Flags().StringVar(&flagMaturityLevel, "maturity-level", "", "CMMI maturity level (NONE, INITIAL, MANAGED, DEFINED, QUANTITATIVELY_MANAGED, OPTIMIZING). Empty string clears the value.")
cmd.Flags().StringVar(&flagMaturityLevel, "maturity-level", "", "CMMI maturity level (NONE, INITIAL, MANAGED, DEFINED, QUANTITATIVELY_MANAGED, OPTIMIZING)")
cmd.Flags().StringVar(&flagNotImplementedJustification, "not-implemented-justification", "", "Justification when maturity level is NONE")
return cmd
}

View File

@@ -22,6 +22,8 @@ import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cli/api"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/docgen"
)
const viewQuery = `
@@ -34,7 +36,6 @@ query($id: ID!) {
name
description
bestPractice
implemented
notImplementedJustification
maturityLevel
framework {
@@ -56,9 +57,8 @@ type viewResponse struct {
Name string `json:"name"`
Description *string `json:"description"`
BestPractice bool `json:"bestPractice"`
Implemented string `json:"implemented"`
NotImplementedJustification *string `json:"notImplementedJustification"`
MaturityLevel *string `json:"maturityLevel"`
MaturityLevel string `json:"maturityLevel"`
Framework struct {
ID string `json:"id"`
Name string `json:"name"`
@@ -144,17 +144,11 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
bp = "Yes"
}
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Best Practice:"), bp)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Implemented:"), c.Implemented)
if c.Implemented == "NOT_IMPLEMENTED" && c.NotImplementedJustification != nil && *c.NotImplementedJustification != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Maturity:"), docgen.MaturityLabel(coredata.ControlMaturityLevel(c.MaturityLevel)))
if c.MaturityLevel == "NONE" && c.NotImplementedJustification != nil && *c.NotImplementedJustification != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Justification:"), *c.NotImplementedJustification)
}
maturity := "Not set"
if c.MaturityLevel != nil {
maturity = *c.MaturityLevel
}
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Maturity:"), maturity)
_, _ = fmt.Fprintln(out)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Created:"), cmdutil.FormatTime(c.CreatedAt))
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Updated:"), cmdutil.FormatTime(c.UpdatedAt))