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

@@ -30,18 +30,17 @@ import (
type (
Control struct {
ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"`
SectionTitle string `db:"section_title"`
FrameworkID gid.GID `db:"framework_id"`
Name string `db:"name"`
Description *string `db:"description"`
BestPractice bool `db:"best_practice"`
Implemented ControlImplementationState `db:"implemented"`
NotImplementedJustification *string `db:"not_implemented_justification"`
MaturityLevel *ControlMaturityLevel `db:"maturity_level"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"`
SectionTitle string `db:"section_title"`
FrameworkID gid.GID `db:"framework_id"`
Name string `db:"name"`
Description *string `db:"description"`
BestPractice bool `db:"best_practice"`
NotImplementedJustification *string `db:"not_implemented_justification"`
MaturityLevel ControlMaturityLevel `db:"maturity_level"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Controls []*Control
@@ -134,7 +133,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -155,7 +153,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -249,7 +246,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -270,7 +266,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -370,7 +365,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -397,7 +391,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -479,7 +472,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -576,7 +568,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -597,7 +588,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -646,7 +636,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -697,7 +686,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -747,7 +735,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -794,7 +781,6 @@ INSERT INTO
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -809,7 +795,6 @@ VALUES (
@name,
@description,
@best_practice,
@implemented,
@not_implemented_justification,
@maturity_level,
@created_at,
@@ -826,7 +811,6 @@ VALUES (
"name": c.Name,
"description": c.Description,
"best_practice": c.BestPractice,
"implemented": c.Implemented,
"not_implemented_justification": c.NotImplementedJustification,
"maturity_level": c.MaturityLevel,
"created_at": c.CreatedAt,
@@ -880,7 +864,6 @@ UPDATE controls SET
description = @description,
section_title = @section_title,
best_practice = @best_practice,
implemented = @implemented,
not_implemented_justification = @not_implemented_justification,
maturity_level = @maturity_level,
updated_at = @updated_at
@@ -895,7 +878,6 @@ WHERE %s
"description": c.Description,
"section_title": c.SectionTitle,
"best_practice": c.BestPractice,
"implemented": c.Implemented,
"not_implemented_justification": c.NotImplementedJustification,
"maturity_level": c.MaturityLevel,
"updated_at": c.UpdatedAt,
@@ -936,7 +918,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -957,7 +938,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,
@@ -1009,7 +989,6 @@ WITH ctrl AS (
c.name,
c.description,
c.best_practice,
c.implemented,
c.not_implemented_justification,
c.maturity_level,
c.created_at,
@@ -1030,7 +1009,6 @@ SELECT
name,
description,
best_practice,
implemented,
not_implemented_justification,
maturity_level,
created_at,

View File

@@ -1,66 +0,0 @@
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"database/sql/driver"
"fmt"
)
type (
ControlImplementationState string
)
const (
ControlImplementationStateImplemented ControlImplementationState = "IMPLEMENTED"
ControlImplementationStateNotImplemented ControlImplementationState = "NOT_IMPLEMENTED"
)
func (s ControlImplementationState) IsValid() bool {
switch s {
case ControlImplementationStateImplemented, ControlImplementationStateNotImplemented:
return true
}
return false
}
func (s ControlImplementationState) String() string {
return string(s)
}
func (s ControlImplementationState) MarshalText() ([]byte, error) {
return []byte(s.String()), nil
}
func (s *ControlImplementationState) UnmarshalText(data []byte) error {
val := ControlImplementationState(data)
if !val.IsValid() {
return fmt.Errorf("invalid ControlImplementationState value: %q", string(data))
}
*s = val
return nil
}
func (s *ControlImplementationState) Scan(value any) error {
val, ok := value.(string)
if !ok {
return fmt.Errorf("invalid scan source for ControlImplementationState, expected string got %T", value)
}
return s.UnmarshalText([]byte(val))
}
func (s ControlImplementationState) Value() (driver.Value, error) {
return s.String(), nil
}

View File

@@ -32,6 +32,17 @@ const (
ControlMaturityLevelOptimizing ControlMaturityLevel = "OPTIMIZING"
)
func ControlMaturityLevels() []ControlMaturityLevel {
return []ControlMaturityLevel{
ControlMaturityLevelNone,
ControlMaturityLevelInitial,
ControlMaturityLevelManaged,
ControlMaturityLevelDefined,
ControlMaturityLevelQuantitativelyManaged,
ControlMaturityLevelOptimizing,
}
}
func (l ControlMaturityLevel) IsValid() bool {
switch l {
case ControlMaturityLevelNone,

View File

@@ -12,4 +12,25 @@
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
ALTER TABLE controls ADD COLUMN maturity_level TEXT;
CREATE TYPE control_maturity_level AS ENUM (
'NONE',
'INITIAL',
'MANAGED',
'DEFINED',
'QUANTITATIVELY_MANAGED',
'OPTIMIZING'
);
ALTER TABLE controls ADD COLUMN maturity_level control_maturity_level;
UPDATE controls SET maturity_level = CASE
WHEN implemented = 'NOT_IMPLEMENTED' THEN 'NONE'::control_maturity_level
ELSE 'INITIAL'::control_maturity_level
END;
ALTER TABLE controls ALTER COLUMN maturity_level SET NOT NULL;
ALTER TABLE controls ALTER COLUMN implemented DROP NOT NULL;
-- TODO: drop column and type in a future migration
-- ALTER TABLE controls DROP COLUMN implemented;
-- DROP TYPE control_implementation_state;