risk

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package risk computes a deterministic, tier-floored risk profile and a thin threat-model summary for an initiative's changes (§31). It contains no LLM logic: the tier floor, the marker scan, and the summary are all deterministic functions of the diff text so the same inputs always produce the same outputs.

Index

Constants

View Source
const (
	SignalAuth       = "auth"
	SignalSecret     = "secret"
	SignalNetwork    = "network"
	SignalCredential = "credential"
	SignalPayment    = "payment"
	SignalPII        = "pii"
)

Signal names produced by the deterministic marker scan. These names are the canonical categories consumed by ComputeRiskProfile's tier floor.

Variables

This section is empty.

Functions

func ComputeRiskProfile

func ComputeRiskProfile(initiativeID string, signals []domain.RiskSignal) domain.RiskProfile

ComputeRiskProfile builds a RiskProfile whose tier is the deterministic floor implied by the detected signals: any detected auth, secret, network, or credential signal floors the profile at high; any detected payment or pii signal floors it at medium; otherwise the floor is low. The returned tier is a minimum, never a ceiling: callers may raise it (see Raise) but the floor computed here can never be lowered by downstream logic.

func Raise

func Raise(a, b domain.RiskTier) domain.RiskTier

Raise returns the higher of two tiers. It is the caller-facing escalation hook: a profile's deterministic floor can be raised (e.g. to domain.RiskCritical) but never lowered, so callers apply it as

p.Tier = risk.Raise(p.Tier, domain.RiskCritical)

func RiskSignals

func RiskSignals(ctx context.Context, patchDigest, diffText string) []domain.RiskSignal

RiskSignals deterministically scans a diff/patch string for known risk markers and returns one domain.RiskSignal per detected category, each with Detected=true. Signals are emitted in markerCatalog order and are deduplicated by category; Detail records every marker that contributed to a category.

ctx and patchDigest are reserved for future policy hooks (e.g. per-initiative sensitivity or provenance linking); the scan itself keys only on diffText.

func ThreatModelSummary

func ThreatModelSummary(signals []domain.RiskSignal) string

ThreatModelSummary returns a deterministic one-paragraph threat-model summary naming the detected risk categories and a generic mitigation. It performs no LLM call and no ranking beyond the signal categories themselves.

Types

This section is empty.

Jump to

Keyboard shortcuts

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