Skip to main content

SEA DSL - Semantic Enterprise Architecture Domain Specific Language

Project description

SEA DSL

PyPI Python Versions License CI

Python bindings for the SEA DSL (Semantic Enterprise Architecture) domain-specific language. Part of the DomainForge ecosystem.

Features

  • 🏗️ 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

Installation

pip install sea-dsl

Requires: Python 3.11+

Quick Start

Parse from DSL

import sea_dsl

source = '''
    @namespace "supply_chain"

    Entity "Warehouse" in logistics
    Entity "Factory" in manufacturing

    Resource "Cameras" units

    Flow "Cameras" from "Warehouse" to "Factory" quantity 100
'''

graph = sea_dsl.Graph.parse(source)

print(f"Entities: {graph.entity_count()}")
print(f"Resources: {graph.resource_count()}")
print(f"Flows: {graph.flow_count()}")

Build Programmatically

import sea_dsl

graph = sea_dsl.Graph()

# Create primitives
warehouse = sea_dsl.Entity("Warehouse", "logistics")
factory = sea_dsl.Entity("Factory", "manufacturing")
cameras = sea_dsl.Resource("Cameras", "units")

graph.add_entity(warehouse)
graph.add_entity(factory)
graph.add_resource(cameras)

# Create flow
flow = sea_dsl.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()}")

Work with Attributes

entity = sea_dsl.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"

CALM Integration

# Export to CALM JSON
calm_json = graph.export_calm()

# Import from CALM
imported_graph = sea_dsl.Graph.import_calm(calm_json)

API Reference

Core Classes

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

Graph Methods

# 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)

NamespaceRegistry

# Load workspace registry
reg = sea_dsl.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')

Development

Building from Source

# 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/

Using Just (Recommended)

just python-setup    # Create venv and install deps
just python-test     # Run test suite
just python-clean    # Remove venv

Platform Support

Pre-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.

Related Packages

Package Registry Description
sea-core crates.io Rust core library
sea-dsl PyPI Python bindings (this package)
@domainforge/sea npm TypeScript/Node.js bindings

Policy Authority

DomainForge includes a Policy Authority system for executable business authority:

from sea_dsl 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, Reject
  • PolicyModality — Permission, Prohibition, Obligation, Override
  • SourceClass — CallerSupplied, RuntimeObserved, SystemOfRecord, Attested, ManualApproval, Derived, UnknownSource
  • ClaimLevel — AuditBacked, Validated, FormallyProven
  • AuthorityEnvironment — Full authority evaluation environment
  • evaluate_authority() — One-shot evaluation function

Documentation

License

Apache-2.0


Part of the DomainForge project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sea_dsl-0.11.0.tar.gz (344.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sea_dsl-0.11.0-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11Windows x86-64

sea_dsl-0.11.0-cp311-cp311-manylinux_2_34_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

sea_dsl-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

sea_dsl-0.11.0-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

sea_dsl-0.11.0-cp311-cp311-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file sea_dsl-0.11.0.tar.gz.

File metadata

  • Download URL: sea_dsl-0.11.0.tar.gz
  • Upload date:
  • Size: 344.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.1

File hashes

Hashes for sea_dsl-0.11.0.tar.gz
Algorithm Hash digest
SHA256 6103751012b757bdb50a5d8910b8d4fb9ca8a498b87a97c15bdf19f42ee80d47
MD5 c1c37efff5df943fa2a9390b4f83441b
BLAKE2b-256 efdae1564f9bc02b225255901eedd2ec1d86ae580ef320f64d6cae53621f0937

See more details on using hashes here.

File details

Details for the file sea_dsl-0.11.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for sea_dsl-0.11.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2bbd4de388f8b1a12180c57323bb2447afab9db75eca0490d3b458d04e8fa9a7
MD5 147bc313490fce101d0dd5887d697153
BLAKE2b-256 9171b5d0e44cdf4690a0a04c84cb8c9fa087f29c1645468368cca56c2e93b136

See more details on using hashes here.

File details

Details for the file sea_dsl-0.11.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for sea_dsl-0.11.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5092747e72cf481eb0811e2b5db02282d66d35a2f7fdfc7bb2f2f5a1a43b95c9
MD5 1aa01de26c5f61d0d9c21ee0710fa8dd
BLAKE2b-256 65af9e8b713f67b85f7e010d1dd25bc6577cd555d7e2ad2f08315b257ea0a313

See more details on using hashes here.

File details

Details for the file sea_dsl-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for sea_dsl-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 af267e73383c8c8b6a54b3cc5931016866d694c5e1b48aedb7d1817e331d4793
MD5 0758d1dfc9fc6fa2a9be3772efeb31fa
BLAKE2b-256 2f9a84bbf8bfe778e5a13b32f5f2cea42d959dfe81927b64649f948a40d3949c

See more details on using hashes here.

File details

Details for the file sea_dsl-0.11.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sea_dsl-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af75660b2f23aba272a886ad3693470ac2de1fcb0785a059d1303c49444c5023
MD5 ceed7c0ea5c74c2300453967ce4e8ada
BLAKE2b-256 606589c4a6cf47cf005b7c7f037edcb6f03ebcaa1c81874458ff9c8329a928bf

See more details on using hashes here.

File details

Details for the file sea_dsl-0.11.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sea_dsl-0.11.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ac478b05fb556188ddbd3261457e0cacd956485be67ccc80be70a204904d7474
MD5 6daa00b0edf488d3d0e6e9d92c87d989
BLAKE2b-256 66a2223bf7b19dc9862af596bda410a62a38fb8c626933cbf77f759432631302

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page