Python bindings for the SEA DSL (Semantic Enterprise Architecture) domain-specific language. Part of the DomainForge ecosystem.
- 🏗️ Domain Primitives — Entities, Resources, Flows, Roles, Relations, Instances
- 📐 Unit System — First-class dimensional analysis with type-safe quantities
- ✅ Policy Engine — Constraint validation with three-valued logic
- 🔄 DSL Parsing — Parse SEA source code into queryable graph structures
- 🌐 CALM Integration — Export/import FINOS CALM architecture-as-code format
- ⚡ Native Performance — Rust-powered core via PyO3
Parsed graphs expose declaration-ordered read access to policies, metrics,
mappings, projections, patterns, concept changes, entity instances, and source
declared dimensions and units. SourceUnit.base_factor is an exact decimal
string; mapping and projection rule details are available through rules_json
and overrides_json.
pip install domainforgeRequires: Python 3.11+
import domainforge
source = '''
@namespace "supply_chain"
Entity "Warehouse" in logistics
Entity "Factory" in manufacturing
Resource "Cameras" units
Flow "Cameras" from "Warehouse" to "Factory" quantity 100
'''
graph = domainforge.Graph.parse(source)
print(f"Entities: {graph.entity_count()}")
print(f"Resources: {graph.resource_count()}")
print(f"Flows: {graph.flow_count()}")import domainforge
graph = domainforge.Graph()
# Create primitives
warehouse = domainforge.Entity("Warehouse", "logistics")
factory = domainforge.Entity("Factory", "manufacturing")
cameras = domainforge.Resource("Cameras", "units")
graph.add_entity(warehouse)
graph.add_entity(factory)
graph.add_resource(cameras)
# Create flow
flow = domainforge.Flow(
cameras.id(),
warehouse.id(),
factory.id(),
100.0
)
graph.add_flow(flow)
# Query the graph
for entity in graph.all_entities():
print(f"{entity.name()} in {entity.namespace()}")entity = domainforge.Entity("Warehouse")
entity.set_attribute("capacity", 10000)
entity.set_attribute("location", "New York")
print(entity.get_attribute("capacity")) # 10000
print(entity.get_attribute("location")) # "New York"# Export to CALM JSON
calm_json = graph.export_calm()
# Import from CALM
imported_graph = domainforge.Graph.import_calm(calm_json)| Class | Description |
|---|---|
Entity |
Business actors, locations, organizational units (WHO) |
Resource |
Quantifiable subjects of value (WHAT) |
Flow |
Transfers of resources between entities |
Instance |
Entity type instances with named fields |
ResourceInstance |
Physical instances at entity locations |
Role |
Roles that entities can play |
Relation |
Relationships between roles |
Graph |
Container with validation and query capabilities |
# Add primitives
graph.add_entity(entity)
graph.add_resource(resource)
graph.add_flow(flow)
graph.add_instance(instance)
graph.add_role(role)
graph.add_relation(relation)
# Counts
graph.entity_count()
graph.resource_count()
graph.flow_count()
# Lookup
graph.find_entity_by_name("Warehouse")
graph.find_resource_by_name("Cameras")
# Flow queries
graph.flows_from(entity_id)
graph.flows_to(entity_id)
# Get all
graph.all_entities()
graph.all_resources()
graph.all_flows()
# Policy evaluation
graph.add_policy(policy)
graph.evaluate_policy(policy_json)
graph.set_evaluation_mode(use_three_valued=True)
# CALM integration
graph.export_calm()
Graph.import_calm(json_str)# Load workspace registry
reg = domainforge.NamespaceRegistry.from_file('.sea-registry.toml')
# Resolve files
for binding in reg.resolve_files():
print(f"{binding.path} => {binding.namespace}")
# Query namespace for file
ns = reg.namespace_for('/path/to/file.sea')# Clone the repository
git clone https://github.com/GodSpeedAI/DomainForge.git
cd DomainForge
# Install maturin
pip install maturin
# Build and install in development mode
maturin develop
# Run tests
pytest tests/just python-setup # Create venv and install deps
just python-test # Run test suite
just python-clean # Remove venvPre-built wheels are available for:
| Platform | Architectures |
|---|---|
| Linux | x86_64, aarch64 |
| macOS | x86_64, arm64 (Apple Silicon) |
| Windows | x86_64 |
Build from source for other platforms.
DomainForge includes a Policy Authority system for executable business authority:
from domainforge import AuthorityEnvironment, evaluate_authority
# Create and validate environment
env = AuthorityEnvironment(config_json)
env.validate()
# Evaluate a request
trace_json, decision_json = env.evaluate(request_json, facts_json)
# Or use the convenience function
trace, decision = evaluate_authority(config_json, request_json, facts_json)Available types:
FinalDecision— Allow, Deny, Escalate, NotApplicable, RejectPolicyModality— Permission, Prohibition, Obligation, OverrideSourceClass— CallerSupplied, RuntimeObserved, SystemOfRecord, Attested, ManualApproval, Derived, UnknownSourceClaimLevel— AuditBacked, Validated, FormallyProvenAuthorityEnvironment— Full authority evaluation environmentevaluate_authority()— One-shot evaluation function
- 📖 SEA DSL Guide — Language specification
- 🏗️ Architecture — Design overview
- 📚 API Reference — Full Python API
Part of the DomainForge project.
