Skip to content

Safety & Alignment

Constructive safety verification and alignment enforcement -- ensuring G6 agents operate within configured pre-execution risk bounds (policy priors, not formal proofs), not just tested ones.

Overview

Safety in G6 is not a post-hoc audit. The Constructive Safety Framework (CSF) computes a pre-execution risk bound via union-bound and worst-case analysis before any action executes; these bounds are policy priors, not mathematical guarantees of safety. Components in this cluster define hazard signatures, verify safety queries against bounded agents, and manage git-based rollback when violations occur.

The alignment side manages specifications, evaluation metrics, prompt governance, and co-constructive alignment processes. align_prompt_library versions every prompt template with automatic increment, while align_evals computes accuracy, precision, recall, F1, and MSE without external ML dependencies.

Together, these ten components form a closed loop: specs record what is allowed, CSF checks bounded safety conditions, evals measure conformance, and prompt governance keeps LLM inputs within alignment boundaries. align_specs should be read as a checklist/rubric compliance layer unless paired with solver-backed components; a passing spec check is not, by itself, proof of regulated-domain compliance.

Components

Component Description MCP Tools
csf SafetyVerifier (union_bound, worst_case), GitRollbackManager --
csf_cognitive Cognitive safety patterns and metacognitive monitoring --
csf_strategy Strategic safety planning and risk assessment --
align_csf G6 safety signature, hazard definitions, csf_guarded decorator --
align_specs Lightweight specification, checklist, and compliance-score management 25
align_evals Evaluation metrics (accuracy, F1, MSE, MAE) --
align_prompt_library Versioned prompt templates, AlignmentSpec, AlignmentBlock 13
align_artifacts Alignment artifact tracking and provenance --
align_coconstructive Co-constructive alignment processes --
align_verbsamp Heuristic verbal alignment monitoring for review, not hard safety gating --

Architecture

graph TD
    CSF[csf] --> CORE[core.ResourceBounds]
    CSF_COG[csf_cognitive] --> CSF
    CSF_STRAT[csf_strategy] --> CSF
    ACSF[align_csf] --> CSF
    SPECS[align_specs] --> CORE
    EVALS[align_evals] --> CORE
    PROMPT[align_prompt_library] --> SPECS
    ART[align_artifacts] --> SPECS
    COCON[align_coconstructive] --> EVALS
    VERB[align_verbsamp] --> EVALS
    ACSF -->|G6_SAFETY_SIGNATURE| SPECS

Key Patterns

CSF Guarded Decorator. @csf_guarded() wraps any function with automatic safety verification. It constructs a SafetyQuery from the function's resource profile, runs it through SafetyVerifier, and blocks execution if the cumulative hazard probability exceeds G6_EPSILON (0.20).

Alignment Spec Lifecycle. Specifications flow through create/store -> validate -> check_compliance/validate_compliance -> export. Each spec carries natural-language clauses and lightweight predicate checks for required phrases, forbidden phrases, regexes, word-count bounds, and simple keyword constraints. Use these checks as review and gating signals; use formal_methods, csf, or domain-specific review for claims that require proof or regulated assurance.

Hazard Signatures. G6 defines five core hazards with pre-calibrated probabilities: llm_call=0.05, file_write=0.01, code_execute=0.10, external_api=0.08, rollback=0.001. These feed into union-bound calculations that give conservative safety guarantees.