πŸ›‘οΈ SEAβ„’ Governance Hooks

Injecting SEAβ„’ validation into generated projects.


Overview

SEAβ„’ governance hooks ensure all generated projects include:


Hook Injection Points

1
2
3
4
5
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Pre-Generation   β”‚ β†’  β”‚ File Generation  β”‚ β†’  β”‚ Post-Generation  β”‚
β”‚ - Validate input β”‚    β”‚ - Create files   β”‚    β”‚ - Add hooks      β”‚
β”‚ - Check context  β”‚    β”‚ - Apply template β”‚    β”‚ - Configure CI   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Pre-Commit Hook

.pre-commit-config.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
repos:
  - repo: local
    hooks:
      - id: sea-validate
        name: SEAβ„’ DSL Validation
        entry: sea validate
        language: system
        files: \.sea$
        
      - id: calm-validate
        name: CALM Architecture Check
        entry: calm validate
        language: system
        files: \.(arch|calm)\.json$
        
      - id: spec-check
        name: Spec Traceability
        entry: node scripts/spec-cross-check.js
        language: system
        pass_filenames: false

Post-Generation Hook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# hooks/post_gen.py
import os
import json

def inject_sea_hooks():
    """Add SEAβ„’ validation to generated project."""
    
    if not os.environ.get('include_sea_governance', 'true') == 'true':
        return
    
    # 1. Add pre-commit configuration
    add_precommit_config()
    
    # 2. Add SEAβ„’ configuration
    add_sea_config()
    
    # 3. Add CI validation step
    add_ci_validation()

def add_sea_config():
    """Create sea.config.json."""
    config = {
        "boundedContext": os.environ.get('sea_bounded_context', 'developer-tooling'),
        "validation": {
            "enabled": True,
            "strict": True
        },
        "ifl": {
            "enabled": os.environ.get('include_ifl_identity', 'true') == 'true',
            "mintOnGenerate": True
        }
    }
    
    with open('sea.config.json', 'w') as f:
        json.dump(config, f, indent=2)

def add_ci_validation():
    """Add SEAβ„’ validation to GitHub Actions."""
    ci_step = """
      - name: SEAβ„’ Validation
        run: |
          sea validate models/
          calm validate
          node scripts/spec-cross-check.js --mode production
"""
    # Append to workflow file...

Configuration File

sea.config.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "boundedContext": "cognitive-extension",
  "validation": {
    "enabled": true,
    "strict": true,
    "rules": ["no-orphan-specs", "trace-to-prd"]
  },
  "ifl": {
    "enabled": true,
    "mintOnGenerate": true,
    "algorithm": "sha256"
  },
  "calm": {
    "enabled": true,
    "architectureFile": "architecture.calm.json"
  }
}

Validation Commands

1
2
3
4
5
6
7
# Full SEAβ„’ validation
just ai-validate

# Individual checks
sea validate models/
calm validate
node scripts/spec-cross-check.js --mode staging

Policies

GovernanceInjection

Policy "GovernanceInjection" per Constraint Obligation priority 10 as:
  forall p in projects:
    (p.has_sea_validation = true AND p.has_ifl_minting = true)

ProtectedRegionIntegrity

Policy "ProtectedRegionIntegrity" per Constraint Obligation priority 10 as:
  forall f in flows where f.name = "SafeWrite":
    (f.respects_protected_regions = true)

Protected Regions

Generators respect human-authored code marked with protected regions:

1
2
3
4
5
6
// @sea-protected-start
// This code will NOT be overwritten by generators
function customLogic() {
  // Human-written implementation
}
// @sea-protected-end