Declarative intent-based execution with preconditions, fallbacks, and nested intent tracing
Project description
intentpy
intentpy is a lightweight Python library for intent-based execution — where what you want to do is declared separately from whether it is allowed to happen.
It provides:
- Declarative preconditions
- Explicit fallback policies
- Nested intent execution
- Structured, readable runtime traces
This is not a circuit breaker or workflow engine. It is a semantic execution layer.
Why intentpy?
Traditional decorators answer:
“Should this function run?”
Intent-based execution answers:
“What is the intent, what does it require, and what happens if it fails?”
This makes complex logic:
- composable
- debuggable
- intention-revealing
Core Concepts
Intent
An intent represents a meaningful action:
- it has requirements
- it produces effects
- it may fail gracefully
Condition
Reusable boolean predicates that gate execution.
Fallback
Named handlers that execute when an intent cannot proceed.
Nesting
Intents can call other intents. Execution is tracked as a runtime tree.
Example: Nested Intent Execution
from intentpy import intent, condition, fallback, ExecutionContext
class User:
def __init__(self, authenticated: bool):
self.is_authenticated = authenticated
@condition("user_authenticated")
def is_authenticated(ctx):
return ctx.user.is_authenticated
@fallback("log_only")
def log_only(ctx, intent):
print(f"Handled failure for intent: {intent.name}")
@intent(
name="send_email",
requires=["user_authenticated"],
effects=["email_sent"],
on_fail="log_only"
)
def send_email(ctx):
print("Sending email...")
@intent(
name="process_order",
requires=["user_authenticated"],
effects=["order_processed"],
on_fail="log_only"
)
def process_order(ctx):
send_email(ctx=ctx)
ctx = ExecutionContext(user=User(authenticated=True))
process_order(ctx=ctx)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file intentpy-0.1.0.tar.gz.
File metadata
- Download URL: intentpy-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e01a54e30998bcaa2db4631e40469ed4bd8fa456f76a3d786d33d4b4a1fdca35
|
|
| MD5 |
80198dd5731c1fc430f20e7c08e168ad
|
|
| BLAKE2b-256 |
37c8df37be49cdb61efc9c176333fbee1be257a6ccb7ce093f060d78a429289a
|
File details
Details for the file intentpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: intentpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59f9b8eaacaec7b039f59e6369dd2108c4a40a20f943274e1a940669e69f220d
|
|
| MD5 |
71de9b0864675cbde7553a01415f9f8d
|
|
| BLAKE2b-256 |
b2cc88d64647177b1b23f03562f597b864b98ed9b1ba7d3813f112a7c694db27
|