Skip to main content

Semantic Action Grammar — a DSL for structured inter-agent communication, with parsing, validation, correlation, and fold-based context compression.

Project description

semantic-action-grammar

Semantic Action Grammar (SAG) — a DSL for structured inter-agent communication.

SAG provides parsing, schema validation, correlation, sanitization, and a grammar-level fold/unfold protocol for context compression. This package is the Python implementation; the canonical grammar lives in the main repository.

Install

pip install semantic-action-grammar

The Python import name is sag:

from sag import SAGMessageParser

Quick start

from sag import SAGMessageParser, MessageMinifier

parser = SAGMessageParser()
message = parser.parse('[id=1 src=A dst=B] DO deploy("app1", version=42) BECAUSE balance>1000;')

print(message.header.id)          # "1"
print(message.statements[0].verb) # "deploy"

# Re-serialize to the compact wire format
print(MessageMinifier().minify(message))

What's in the box

  • ParserSAGMessageParser, ANTLR4-backed
  • Schema validationSchemaRegistry, VerbSchema, SchemaValidator
  • GuardrailsBECAUSE-clause expressions evaluated against a Context
  • Sanitizer — four-layer firewall (parse → routing → schema → guardrail)
  • Fold protocolFoldEngine for lossless conversation compression
  • Knowledge engine — versioned topic-based fact propagation
  • Tree / Grove — multi-agent topology and bottom-up orchestration
  • Accounting — token and cost tracking for grove executions

See the main repository for benchmarks, the chatbot demo, and the full specification.

License

MIT — see LICENSE.

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

semantic_action_grammar-1.0.1.tar.gz (62.4 kB view details)

Uploaded Source

Built Distribution

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

semantic_action_grammar-1.0.1-py3-none-any.whl (73.9 kB view details)

Uploaded Python 3

File details

Details for the file semantic_action_grammar-1.0.1.tar.gz.

File metadata

  • Download URL: semantic_action_grammar-1.0.1.tar.gz
  • Upload date:
  • Size: 62.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for semantic_action_grammar-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e355c085535d924fccd510830620b1a78d8784011a923ddfa8aa94e436d5d80b
MD5 1b7b4c4545d9267c5f87bafa545cd480
BLAKE2b-256 bec83f0bea8925f9186a674ae1672c83a7ba559c2b5510f66c18e5315f4d3d6f

See more details on using hashes here.

File details

Details for the file semantic_action_grammar-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_action_grammar-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8728efbbcb0a645e7e34bc638215f4934ae2072143ee55db792bdcb99a14e8b
MD5 b15327582a7b7f1b3572a4d6a8a1cafc
BLAKE2b-256 493436b8448b7526d93ffd1eded78e21243537c8ed92975123d3a93d041dc558

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