prism

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

README

PRISM

Proactive Reliability & Security Maturity Model

PRISM is a unified framework for B2B SaaS health metrics that combines SLOs, DMAIC, OKRs, and maturity modeling into a single coherent system. It provides structured schemas for defining metrics, calculating composite health scores, and tracking organizational maturity across security and operations domains.

Installation

go install github.com/grokify/prism/cmd/prism@latest

Or add as a library dependency:

go get github.com/grokify/prism

CLI Usage

Initialize a new PRISM document
# Create default document with both domains
prism init

# Create security-focused document
prism init -d security -o security.json

# Create operations-focused document
prism init -d operations -o ops.json
Validate a document
prism validate prism.json
Calculate PRISM score
# Basic score
prism score prism.json

# Detailed breakdown
prism score prism.json --detailed

# JSON output
prism score prism.json --json
List available constants
prism catalog

Schema Overview

Domains

PRISM organizes metrics into two primary domains:

Domain Description
security Application and infrastructure security metrics
operations Reliability, performance, and efficiency metrics
Lifecycle Stages

Metrics are mapped to software delivery lifecycle stages:

Stage Description
design Architecture, threat modeling, requirements
build CI/CD, SAST, dependency scanning
test Testing coverage, penetration testing
runtime Production monitoring, availability, detection
response Incident response, remediation, recovery
Categories
Category Description
prevention Proactive controls that prevent issues
detection Monitoring and alerting capabilities
response Incident handling and remediation
reliability Availability and durability
efficiency Performance and resource utilization
quality Code and process quality
Metric Types
Type Description Example
coverage Percentage of coverage SAST coverage
rate Frequency or percentage Error rate
latency Time duration P99 latency, MTTR
ratio Proportion Success ratio
count Absolute count Incident count
distribution Statistical distribution Latency percentiles
score Composite score Security score

Example Metric

{
  "id": "ops-availability",
  "name": "Service Availability",
  "description": "Percentage of time the service is available",
  "domain": "operations",
  "stage": "runtime",
  "category": "reliability",
  "metricType": "rate",
  "trendDirection": "higher_better",
  "unit": "%",
  "baseline": 99.0,
  "current": 99.95,
  "target": 99.99,
  "thresholds": {
    "green": 99.95,
    "yellow": 99.9,
    "red": 99.0
  },
  "slo": {
    "target": ">=99.99%",
    "operator": "gte",
    "value": 99.99,
    "window": "30d"
  },
  "frameworkMappings": [
    {"framework": "SRE", "reference": "availability-slo"},
    {"framework": "DORA", "reference": "availability"}
  ]
}

PRISM Score Calculation

The PRISM score combines maturity levels, metric performance, and customer awareness into a composite health score (0.0-1.0).

Formula
CellScore = (MaturityWeight × MaturityScore) + (PerformanceWeight × PerformanceScore)
BaseScore = Σ(CellScore × Weight) / Σ(Weight)
Overall = BaseScore × AwarenessScore
Default Weights

Component weights:

  • Maturity: 40%
  • Performance: 60%

Stage weights:

  • Design: 15%
  • Build: 20%
  • Test: 15%
  • Runtime: 30%
  • Response: 20%

Domain weights:

  • Security: 50%
  • Operations: 50%
Score Interpretation
Score Level Description
≥0.90 Elite Industry-leading practices
≥0.75 Strong Well-managed, proactive
≥0.50 Medium Adequate, room for improvement
≥0.25 Weak Significant gaps
<0.25 Critical Immediate attention required

Maturity Levels

PRISM uses a 5-level maturity model:

Level Name Description
1 Reactive Ad-hoc processes, firefighting mode
2 Basic Basic controls, some documentation
3 Defined Standardized processes, consistent execution
4 Managed Data-driven, measured and controlled
5 Optimizing Continuous improvement, automated optimization

Framework Mappings

PRISM metrics can be mapped to external frameworks:

Framework Description
NIST_CSF NIST Cybersecurity Framework
MITRE_ATTACK MITRE ATT&CK Framework
DORA DevOps Research and Assessment
SRE Site Reliability Engineering

JSON Schema

The JSON Schema is auto-generated from Go types:

cd schema && go run generate.go

Schema location: schema/prism.schema.json

Use in your editor for validation:

{
  "$schema": "https://github.com/grokify/prism/schema/prism.schema.json",
  "metrics": [...]
}

Examples

See the examples/ directory:

  • security-metrics.json - Security-focused metrics (vulnerability management, SAST, threat modeling)
  • operations-metrics.json - Operations-focused metrics (DORA metrics, SLOs, reliability)

Library Usage

package main

import (
    "encoding/json"
    "fmt"
    "os"

    "github.com/grokify/prism"
)

func main() {
    // Load document
    data, _ := os.ReadFile("prism.json")
    var doc prism.PRISMDocument
    json.Unmarshal(data, &doc)

    // Validate
    if errs := doc.Validate(); errs.HasErrors() {
        fmt.Println("Validation errors:", errs)
        return
    }

    // Calculate score
    score := doc.CalculatePRISMScore(nil, nil)
    fmt.Printf("PRISM Score: %.1f%% (%s)\n", score.Overall*100, score.Interpretation)

    // Check individual metrics
    for _, m := range doc.Metrics {
        status := m.CalculateStatus()
        meetsSLO := m.MeetsSLO()
        fmt.Printf("  %s: %s (SLO met: %v)\n", m.Name, status, meetsSLO)
    }
}

License

MIT

Documentation

Overview

Package prism provides the PRISM (Proactive Reliability & Security Maturity Model) framework for B2B SaaS health metrics combining SLOs, DMAIC, OKRs, and maturity modeling.

Index

Constants

View Source
const (
	DomainSecurity   = "security"
	DomainOperations = "operations"
)

Domain constants represent the two primary domains in PRISM.

View Source
const (
	StageDesign   = "design"
	StageBuild    = "build"
	StageTest     = "test"
	StageRuntime  = "runtime"
	StageResponse = "response"
)

Lifecycle stage constants represent stages in the software delivery lifecycle.

View Source
const (
	CategoryPrevention  = "prevention"
	CategoryDetection   = "detection"
	CategoryResponse    = "response"
	CategoryReliability = "reliability"
	CategoryEfficiency  = "efficiency"
	CategoryQuality     = "quality"
)

Category constants represent metric categories.

View Source
const (
	MaturityLevel1 = 1 // Reactive
	MaturityLevel2 = 2 // Basic
	MaturityLevel3 = 3 // Defined
	MaturityLevel4 = 4 // Managed
	MaturityLevel5 = 5 // Optimizing
)

Maturity level constants represent the 5-level maturity model.

View Source
const (
	AwarenessUnaware          = "unaware"
	AwarenessAwareNotActing   = "aware_not_remediating"
	AwarenessAwareRemediating = "aware_remediating"
	AwarenessAwareRemediated  = "aware_remediated"
)

Customer awareness state constants.

View Source
const (
	FrameworkNISTCSF     = "NIST_CSF"
	FrameworkMITREATTACK = "MITRE_ATTACK"
	FrameworkDORA        = "DORA"
	FrameworkSRE         = "SRE"
)

Framework constants for external framework mappings.

View Source
const (
	MetricTypeCoverage     = "coverage"
	MetricTypeRate         = "rate"
	MetricTypeLatency      = "latency"
	MetricTypeRatio        = "ratio"
	MetricTypeCount        = "count"
	MetricTypeDistribution = "distribution"
	MetricTypeScore        = "score"
)

Metric type constants.

View Source
const (
	TrendHigherBetter = "higher_better"
	TrendLowerBetter  = "lower_better"
	TrendTargetValue  = "target_value"
)

Trend direction constants.

View Source
const (
	StatusGreen  = "Green"
	StatusYellow = "Yellow"
	StatusRed    = "Red"
)

Status constants for metric health.

View Source
const (
	Window7Days  = "7d"
	Window30Days = "30d"
	Window90Days = "90d"
)

SLO window constants.

View Source
const (
	SLOOperatorGTE = "gte" // Greater than or equal
	SLOOperatorLTE = "lte" // Less than or equal
	SLOOperatorEQ  = "eq"  // Equal
	SLOOperatorGT  = "gt"  // Greater than
	SLOOperatorLT  = "lt"  // Less than
)

SLO operator constants.

Variables

This section is empty.

Functions

func AllAwarenessStates

func AllAwarenessStates() []string

AllAwarenessStates returns all valid awareness state values.

func AllCategories

func AllCategories() []string

AllCategories returns all valid category values.

func AllDomains

func AllDomains() []string

AllDomains returns all valid domain values.

func AllFrameworks

func AllFrameworks() []string

AllFrameworks returns all valid framework values.

func AllMetricTypes

func AllMetricTypes() []string

AllMetricTypes returns all valid metric type values.

func AllStages

func AllStages() []string

AllStages returns all valid stage values.

func AllStatuses

func AllStatuses() []string

AllStatuses returns all valid status values.

func AllTrendDirections

func AllTrendDirections() []string

AllTrendDirections returns all valid trend direction values.

func AllWindows

func AllWindows() []string

AllWindows returns all valid SLO window values.

func DefaultAwarenessStates

func DefaultAwarenessStates() []string

DefaultAwarenessStates returns the default four awareness states.

func InterpretScore

func InterpretScore(score float64) string

InterpretScore returns a human-readable interpretation of the PRISM score.

func MaturityLevelName

func MaturityLevelName(level int) string

MaturityLevelName returns the name for a maturity level.

func ValidateAwarenessState

func ValidateAwarenessState(state string) error

ValidateAwarenessState validates an awareness state value.

func ValidateCategory

func ValidateCategory(category string) error

ValidateCategory validates a category value.

func ValidateDomain

func ValidateDomain(domain string) error

ValidateDomain validates a domain value.

func ValidateFramework

func ValidateFramework(framework string) error

ValidateFramework validates a framework value.

func ValidateMaturityLevel

func ValidateMaturityLevel(level int) error

ValidateMaturityLevel validates a maturity level value.

func ValidateMetricType

func ValidateMetricType(metricType string) error

ValidateMetricType validates a metric type value.

func ValidateStage

func ValidateStage(stage string) error

ValidateStage validates a stage value.

func ValidateStatus

func ValidateStatus(status string) error

ValidateStatus validates a status value.

func ValidateTrendDirection

func ValidateTrendDirection(trend string) error

ValidateTrendDirection validates a trend direction value.

func ValidateWindow

func ValidateWindow(window string) error

ValidateWindow validates an SLO window value.

Types

type AwarenessDistribution

type AwarenessDistribution struct {
	State   string  `json:"state"`
	Count   int     `json:"count"`
	Percent float64 `json:"percent"`
}

AwarenessDistribution represents the count and percentage for a single awareness state.

type AwarenessSummary

type AwarenessSummary struct {
	TotalCustomers          int     `json:"totalCustomers"`
	UnawareCount            int     `json:"unawareCount"`
	AwareCount              int     `json:"awareCount"`
	RemediatingCount        int     `json:"remediatingCount"`
	RemediatedCount         int     `json:"remediatedCount"`
	ProactiveDetectionRate  float64 `json:"proactiveDetectionRate"`
	ProactiveResolutionRate float64 `json:"proactiveResolutionRate"`
	AwarenessScore          float64 `json:"awarenessScore"`
}

AwarenessSummary provides a summary view of awareness metrics.

type CellScore

type CellScore struct {
	Domain           string  `json:"domain"`
	Stage            string  `json:"stage"`
	MaturityScore    float64 `json:"maturityScore"`
	PerformanceScore float64 `json:"performanceScore"`
	CellScore        float64 `json:"cellScore"`
	Weight           float64 `json:"weight"`
}

CellScore represents the score for a specific domain/stage cell.

type CustomerAwarenessConfig

type CustomerAwarenessConfig struct {
	Enabled bool     `json:"enabled"`
	States  []string `json:"states,omitempty"`
}

CustomerAwarenessConfig defines whether customer awareness tracking is enabled for a metric.

func NewCustomerAwarenessConfig

func NewCustomerAwarenessConfig(enabled bool) *CustomerAwarenessConfig

NewCustomerAwarenessConfig creates a new config with defaults.

type CustomerAwarenessData

type CustomerAwarenessData struct {
	Period       string                  `json:"period"`
	Distribution []AwarenessDistribution `json:"distribution"`
}

CustomerAwarenessData represents customer awareness distribution for a period.

func NewCustomerAwarenessData

func NewCustomerAwarenessData(period string) *CustomerAwarenessData

NewCustomerAwarenessData creates awareness data with zero counts.

func (*CustomerAwarenessData) AwareNotActingRate

func (d *CustomerAwarenessData) AwareNotActingRate() float64

AwareNotActingRate returns the rate of customers who are aware but not remediating.

func (*CustomerAwarenessData) AwarenessScore

func (d *CustomerAwarenessData) AwarenessScore() float64

AwarenessScore returns a composite awareness score (0.0-1.0). Higher scores indicate better awareness/remediation state. Uses mutually exclusive states with weighted values:

  • unaware: 0.0 (worst - customer doesn't know about the issue)
  • aware_not_acting: 0.25 (customer knows but hasn't started remediation)
  • remediating: 0.5 (customer is actively working on it)
  • remediated: 1.0 (best - customer has resolved the issue)

func (*CustomerAwarenessData) GetStateCount

func (d *CustomerAwarenessData) GetStateCount(state string) int

GetStateCount returns the count for a specific awareness state.

func (*CustomerAwarenessData) GetStatePercent

func (d *CustomerAwarenessData) GetStatePercent(state string) float64

GetStatePercent returns the percentage for a specific awareness state.

func (*CustomerAwarenessData) ProactiveDetectionRate

func (d *CustomerAwarenessData) ProactiveDetectionRate() float64

ProactiveDetectionRate returns 1 - unaware rate (rate of customers who are aware).

func (*CustomerAwarenessData) ProactiveResolutionRate

func (d *CustomerAwarenessData) ProactiveResolutionRate() float64

ProactiveResolutionRate returns the rate of customers who have remediated.

func (*CustomerAwarenessData) RecalculatePercentages

func (d *CustomerAwarenessData) RecalculatePercentages()

RecalculatePercentages recalculates all percentages based on counts.

func (*CustomerAwarenessData) RemediationInProgressRate

func (d *CustomerAwarenessData) RemediationInProgressRate() float64

RemediationInProgressRate returns the rate of customers actively remediating.

func (*CustomerAwarenessData) SetCount

func (d *CustomerAwarenessData) SetCount(state string, count int) error

SetCount sets the count for a specific awareness state and recalculates percentages.

func (*CustomerAwarenessData) Summary

Summary returns a summary of the awareness data.

func (*CustomerAwarenessData) TotalCount

func (d *CustomerAwarenessData) TotalCount() int

TotalCount returns the total count across all awareness states.

func (*CustomerAwarenessData) UnawareRate

func (d *CustomerAwarenessData) UnawareRate() float64

UnawareRate returns the rate (0.0-1.0) of customers who are unaware.

func (*CustomerAwarenessData) Validate

Validate validates the awareness data.

type DMAICMapping

type DMAICMapping struct {
	Define  string `json:"define,omitempty"`
	Measure string `json:"measure,omitempty"`
	Analyze string `json:"analyze,omitempty"`
	Improve string `json:"improve,omitempty"`
	Control string `json:"control,omitempty"`
}

DMAICMapping maps the metric to DMAIC phases.

type DataPoint

type DataPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
	Note      string    `json:"note,omitempty"`
}

DataPoint represents a historical measurement.

type DomainDef

type DomainDef struct {
	Name        string  `json:"name"`
	Description string  `json:"description,omitempty"`
	Weight      float64 `json:"weight,omitempty"`
}

DomainDef defines a PRISM domain (security or operations).

type DomainScoreBreakdown

type DomainScoreBreakdown struct {
	Score         float64 `json:"score"`
	Weight        float64 `json:"weight"`
	MetricCount   int     `json:"metricCount"`
	MaturityLevel float64 `json:"maturityLevel"`
}

DomainScoreBreakdown breaks down scores by domain.

type FrameworkMapping

type FrameworkMapping struct {
	Framework string `json:"framework"`
	Reference string `json:"reference"`
}

FrameworkMapping maps a metric to an external framework reference.

type HealthStatus

type HealthStatus struct {
	Level       string  `json:"level"` // Elite, Strong, Medium, Weak, Critical
	Score       float64 `json:"score"` // 0.0-1.0
	Color       string  `json:"color"` // Green, Yellow, Red
	Description string  `json:"description"`
}

HealthStatus represents overall health based on score.

type Initiative

type Initiative struct {
	ID          string   `json:"id,omitempty"`
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
	Status      string   `json:"status,omitempty"`
	Priority    int      `json:"priority,omitempty"`
	MetricIDs   []string `json:"metricIds,omitempty"`
	Owner       string   `json:"owner,omitempty"`
	StartDate   string   `json:"startDate,omitempty"`
	EndDate     string   `json:"endDate,omitempty"`
}

Initiative represents an improvement initiative.

type MaturityCell

type MaturityCell struct {
	Domain        string  `json:"domain"`
	Stage         string  `json:"stage"`
	CurrentLevel  int     `json:"currentLevel"`
	TargetLevel   int     `json:"targetLevel,omitempty"`
	PrimaryKPI    string  `json:"primaryKPI,omitempty"`
	KPITarget     string  `json:"kpiTarget,omitempty"`
	MaturityScore float64 `json:"maturityScore,omitempty"`
}

MaturityCell represents maturity state for a domain/stage combination.

func (*MaturityCell) CalculateMaturityScore

func (c *MaturityCell) CalculateMaturityScore() float64

CalculateMaturityScore calculates the normalized maturity score (0.0-1.0) for a cell.

type MaturityLevelDef

type MaturityLevelDef struct {
	Level       int    `json:"level"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

MaturityLevelDef defines a maturity level.

func DefaultMaturityLevels

func DefaultMaturityLevels() []MaturityLevelDef

DefaultMaturityLevels returns the standard 5-level maturity definitions.

type MaturityMapping

type MaturityMapping struct {
	Level1 string `json:"level1,omitempty"`
	Level2 string `json:"level2,omitempty"`
	Level3 string `json:"level3,omitempty"`
	Level4 string `json:"level4,omitempty"`
	Level5 string `json:"level5,omitempty"`
}

MaturityMapping maps metric values to maturity levels.

type MaturityModel

type MaturityModel struct {
	Levels []MaturityLevelDef `json:"levels,omitempty"`
	Cells  []MaturityCell     `json:"cells,omitempty"`
}

MaturityModel defines the maturity model configuration and cell scores.

func NewMaturityModel

func NewMaturityModel() *MaturityModel

NewMaturityModel creates a new maturity model with default levels.

func NewMaturityModelForDomains

func NewMaturityModelForDomains(domains []string) *MaturityModel

NewMaturityModelForDomains creates a maturity model with cells for specified domains only.

func NewMaturityModelWithCells

func NewMaturityModelWithCells() *MaturityModel

NewMaturityModelWithCells creates a maturity model with cells for all domain/stage combinations.

func (*MaturityModel) AverageMaturityLevel

func (m *MaturityModel) AverageMaturityLevel() float64

AverageMaturityLevel returns the average maturity level across all cells.

func (*MaturityModel) AverageMaturityScore

func (m *MaturityModel) AverageMaturityScore() float64

AverageMaturityScore returns the average normalized maturity score (0.0-1.0).

func (*MaturityModel) DomainMaturityLevel

func (m *MaturityModel) DomainMaturityLevel(domain string) float64

DomainMaturityLevel returns the average maturity level for a specific domain.

func (*MaturityModel) GetCell

func (m *MaturityModel) GetCell(domain, stage string) *MaturityCell

GetCell returns the maturity cell for a specific domain/stage combination.

func (*MaturityModel) GetCellsByDomain

func (m *MaturityModel) GetCellsByDomain(domain string) []MaturityCell

GetCellsByDomain returns all maturity cells for a specific domain.

func (*MaturityModel) GetCellsByStage

func (m *MaturityModel) GetCellsByStage(stage string) []MaturityCell

GetCellsByStage returns all maturity cells for a specific stage.

func (*MaturityModel) SetCellLevel

func (m *MaturityModel) SetCellLevel(domain, stage string, level int) error

SetCellLevel sets the current maturity level for a domain/stage combination. Creates the cell if it doesn't exist.

func (*MaturityModel) StageMaturityLevel

func (m *MaturityModel) StageMaturityLevel(stage string) float64

StageMaturityLevel returns the average maturity level for a specific stage.

func (*MaturityModel) UpdateMaturityScores

func (m *MaturityModel) UpdateMaturityScores()

UpdateMaturityScores calculates and updates maturity scores for all cells.

func (*MaturityModel) Validate

func (m *MaturityModel) Validate() ValidationErrors

Validate validates the maturity model.

type Metadata

type Metadata struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Version     string `json:"version,omitempty"`
	Author      string `json:"author,omitempty"`
	Created     string `json:"created,omitempty"`
	Updated     string `json:"updated,omitempty"`
}

Metadata contains document-level metadata.

type Metric

type Metric struct {
	// Core identity
	ID          string `json:"id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`

	// PRISM classification
	Domain   string `json:"domain"`
	Stage    string `json:"stage"`
	Category string `json:"category"`

	// Measurement
	MetricType     string  `json:"metricType"`
	TrendDirection string  `json:"trendDirection,omitempty"`
	Unit           string  `json:"unit,omitempty"`
	Baseline       float64 `json:"baseline"`
	Current        float64 `json:"current"`
	Target         float64 `json:"target"`

	// SLI/SLO
	SLI *SLI `json:"sli,omitempty"`
	SLO *SLO `json:"slo,omitempty"`

	// Thresholds & Status
	Thresholds *Thresholds `json:"thresholds,omitempty"`
	Status     string      `json:"status,omitempty"`

	// Maturity mapping
	MaturityMapping *MaturityMapping `json:"maturityMapping,omitempty"`

	// DMAIC mapping
	DMAIC *DMAICMapping `json:"dmaic,omitempty"`

	// Customer awareness
	CustomerAwareness *CustomerAwarenessConfig `json:"customerAwareness,omitempty"`

	// Framework mappings
	FrameworkMappings []FrameworkMapping `json:"frameworkMappings,omitempty"`

	// Ownership
	Owner      string `json:"owner,omitempty"`
	DataSource string `json:"dataSource,omitempty"`

	// History
	DataPoints []DataPoint `json:"dataPoints,omitempty"`
}

Metric represents a PRISM metric with SLO, maturity, and framework mappings.

func (*Metric) CalculateStatus

func (m *Metric) CalculateStatus() string

CalculateStatus computes the status based on current value and thresholds. For higher_better trends: value >= green threshold = Green, etc. For lower_better trends: value <= green threshold = Green, etc.

func (*Metric) MeetsSLO

func (m *Metric) MeetsSLO() bool

MeetsSLO returns whether the metric's current value meets its SLO. Returns true if no SLO is defined or if Operator/Value are not set. Uses the structured Operator and Value fields for evaluation.

func (*Metric) ProgressToTarget

func (m *Metric) ProgressToTarget() float64

ProgressToTarget returns the progress as a ratio (0.0-1.0) toward the target.

func (*Metric) Validate

func (m *Metric) Validate() ValidationErrors

Validate validates a Metric and returns validation errors.

type OKRMapping

type OKRMapping struct {
	ObjectiveID   string   `json:"objectiveId,omitempty"`
	ObjectiveName string   `json:"objectiveName"`
	KeyResultID   string   `json:"keyResultId,omitempty"`
	KeyResultName string   `json:"keyResultName,omitempty"`
	MetricIDs     []string `json:"metricIds,omitempty"`
}

OKRMapping represents alignment between metrics and OKRs.

type PRISMDocument

type PRISMDocument struct {
	Schema      string         `json:"$schema,omitempty"`
	Metadata    *Metadata      `json:"metadata,omitempty"`
	Domains     []DomainDef    `json:"domains,omitempty"`
	Metrics     []Metric       `json:"metrics"`
	Maturity    *MaturityModel `json:"maturity,omitempty"`
	OKRs        []OKRMapping   `json:"okrs,omitempty"`
	Initiatives []Initiative   `json:"initiatives,omitempty"`
}

PRISMDocument represents the top-level PRISM document.

func (*PRISMDocument) CalculatePRISMScore

func (doc *PRISMDocument) CalculatePRISMScore(config *ScoreConfig, awareness *CustomerAwarenessData) *PRISMScore

CalculatePRISMScore calculates the composite PRISM score for a document.

The score is computed as follows:

  1. For each domain/stage cell, compute a CellScore combining: - MaturityScore: currentLevel / 5 (from maturity model) - PerformanceScore: average ProgressToTarget() of metrics in that cell - CellScore = (MaturityWeight × MaturityScore) + (PerformanceWeight × PerformanceScore)

  2. Compute weighted average of all cell scores: - Each cell has weight = DomainWeight × StageWeight - BaseScore = Σ(CellScore × Weight) / Σ(Weight)

  3. Apply awareness multiplier (if provided): - Overall = BaseScore × AwarenessScore - AwarenessScore ranges from 0.0 (all unaware) to 1.0 (all remediated)

  4. Interpret the score: Elite (≥0.9), Strong (≥0.75), Medium (≥0.5), Weak (≥0.25), Critical (<0.25)

Pass nil for config to use DefaultScoreConfig(). Pass nil for awareness to skip the awareness multiplier (defaults to 1.0).

func (*PRISMDocument) GetMetricByID

func (doc *PRISMDocument) GetMetricByID(id string) *Metric

GetMetricByID returns a metric by its ID.

func (*PRISMDocument) GetMetricsByCategory

func (doc *PRISMDocument) GetMetricsByCategory(category string) []Metric

GetMetricsByCategory returns all metrics for the specified category.

func (*PRISMDocument) GetMetricsByDomain

func (doc *PRISMDocument) GetMetricsByDomain(domain string) []Metric

GetMetricsByDomain returns all metrics for the specified domain.

func (*PRISMDocument) GetMetricsByStage

func (doc *PRISMDocument) GetMetricsByStage(stage string) []Metric

GetMetricsByStage returns all metrics for the specified stage.

func (*PRISMDocument) Validate

func (doc *PRISMDocument) Validate() ValidationErrors

Validate validates the entire PRISMDocument.

type PRISMScore

type PRISMScore struct {
	Overall            float64     `json:"overall"`
	BaseScore          float64     `json:"baseScore"`
	AwarenessScore     float64     `json:"awarenessScore"`
	SecurityScore      float64     `json:"securityScore"`
	OperationsScore    float64     `json:"operationsScore"`
	CellScores         []CellScore `json:"cellScores,omitempty"`
	Interpretation     string      `json:"interpretation"`
	MaturityAverage    float64     `json:"maturityAverage,omitempty"`
	PerformanceAverage float64     `json:"performanceAverage,omitempty"`
}

PRISMScore represents the composite PRISM score for a document.

func (*PRISMScore) GetHealthStatus

func (score *PRISMScore) GetHealthStatus() *HealthStatus

GetHealthStatus returns the health status based on the PRISM score.

func (*PRISMScore) GetScoreBreakdown

func (score *PRISMScore) GetScoreBreakdown() *ScoreBreakdown

GetScoreBreakdown returns a detailed breakdown of scores.

type SLI

type SLI struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Formula     string `json:"formula,omitempty"`
}

SLI represents a Service Level Indicator.

type SLO

type SLO struct {
	Target     string      `json:"target"`             // Display string (e.g., ">=99.9%")
	Operator   string      `json:"operator,omitempty"` // Machine-readable: "gte", "lte", "eq", "gt", "lt"
	Value      float64     `json:"value,omitempty"`    // Numeric target value
	Window     string      `json:"window,omitempty"`   // "7d", "30d", "90d"
	Thresholds *Thresholds `json:"thresholds,omitempty"`
}

SLO represents a Service Level Objective.

type ScoreBreakdown

type ScoreBreakdown struct {
	DomainBreakdown map[string]DomainScoreBreakdown `json:"domainBreakdown"`
	StageBreakdown  map[string]StageScoreBreakdown  `json:"stageBreakdown"`
}

ScoreBreakdown provides detailed breakdown of score components.

type ScoreConfig

type ScoreConfig struct {
	MaturityWeight    float64            `json:"maturityWeight"`
	PerformanceWeight float64            `json:"performanceWeight"`
	StageWeights      map[string]float64 `json:"stageWeights"`
	DomainWeights     map[string]float64 `json:"domainWeights"`
}

ScoreConfig configures the PRISM score calculation.

Weight Normalization Behavior

Cell weights are calculated as: DomainWeight × StageWeight

With default config (domain weights 0.5/0.5, stage weights summing to 1.0), each cell weight ranges from 0.075 to 0.15. The total weight across all 10 cells (2 domains × 5 stages) sums to 0.5 (not 1.0).

The final BaseScore divides weightedSum by totalWeight, which normalizes the result. This means:

  • If both domains have equal stage coverage, domain weights are effectively irrelevant (they cancel out in the normalization)
  • Domain weights only affect the score when domains have different coverage
  • To make domain weights meaningful, either: (a) Have different numbers of metrics per domain, or (b) Use domain-specific subscores (SecurityScore, OperationsScore)

The awareness multiplier is applied after normalization:

Overall = BaseScore × AwarenessScore

func DefaultScoreConfig

func DefaultScoreConfig() *ScoreConfig

DefaultScoreConfig returns the default score configuration.

func (*ScoreConfig) GetDomainWeight

func (c *ScoreConfig) GetDomainWeight(domain string) float64

GetDomainWeight returns the weight for a domain, defaulting to equal weight.

func (*ScoreConfig) GetStageWeight

func (c *ScoreConfig) GetStageWeight(stage string) float64

GetStageWeight returns the weight for a stage, defaulting to equal weight.

type StageScoreBreakdown

type StageScoreBreakdown struct {
	Score       float64 `json:"score"`
	Weight      float64 `json:"weight"`
	MetricCount int     `json:"metricCount"`
}

StageScoreBreakdown breaks down scores by stage.

type Thresholds

type Thresholds struct {
	Green  float64 `json:"green"`
	Yellow float64 `json:"yellow"`
	Red    float64 `json:"red"`
}

Thresholds defines threshold values for status calculation.

type ValidationError

type ValidationError struct {
	Field   string
	Value   string
	Message string
}

ValidationError represents a validation error with context.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

ValidationErrors is a collection of validation errors.

func (ValidationErrors) Error

func (ve ValidationErrors) Error() string

func (ValidationErrors) HasErrors

func (ve ValidationErrors) HasErrors() bool

HasErrors returns true if there are any validation errors.

Directories

Path Synopsis
cmd
prism command
Package main provides the prism CLI tool for working with PRISM documents.
Package main provides the prism CLI tool for working with PRISM documents.
Package schema provides embedded JSON Schema for PRISM types.
Package schema provides embedded JSON Schema for PRISM types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL