Skip to main content

ragleap-flows

Multi-tenant flows as plain JSON data: tool steps, approval checkpoints and branches. Every run belongs to a ragleap_security.Scope; a paused run survives a restart and is resumed later, only by the tenant that owns it.

Alpha (0.1.0). MIT. Python 3.10+. Not independently audited.

pip install ragleap-flows

This is not n8n and not a workflow engine with connectors. A flow file holds no code: no eval, no scripts, no string interpolation. It is a small, auditable core for "do these tool calls, ask a human here, branch there".

A flow

{
  "version": 1,
  "steps": [
    {"id": "look", "type": "tool", "tool": "lookup_order", "arguments": {"order": "$input.order"}, "next": "check"},
    {"id": "check", "type": "branch",
     "cases": [{"when": {"path": "$look.amount", "op": "gt", "value": 100}, "goto": "ask"}], "else": "pay"},
    {"id": "ask", "type": "approval", "prompt": "Approve this refund?", "show": {"amount": "$look.amount"}, "next": "pay"},
    {"id": "pay", "type": "tool", "tool": "refund", "outbound": true, "arguments": {"order": "$input.order"}}
  ],
  "output": {"refunded": "$pay.ok"}
}

Step types: tool (tool, arguments, next, outbound, external), approval (prompt, show, next), branch (cases of when and goto, then else). A missing next ends the run.

Values move between steps with paths: $input.x and $step_id.field.0. A string that is exactly a path is replaced by the value it points at (dict keys by name, list items by position). There is no interpolation and no attribute access; "$$x" is the literal text $x. Operators: eq ne lt le gt ge in exists truthy, combined with all and any. A number never equals a True, and a missing value satisfies no comparison (not even ne).

Run it

import ragleap_flows as rf
from ragleap_security import Scope

flow = rf.from_json(open("refund.json").read())          # checked once, strictly
runner = rf.FlowRunner(flow, toolkit, store=my_store)    # toolkit: a ragleap_tools Toolkit
tenant = Scope("acme")                                   # the host authenticates; the library never does

result = runner.run(tenant, {"order": "A-17"})
if result.status == "awaiting_approval":
    result = runner.resume(tenant, result.run_id, {result.pending["step"]: True})

status is one of done, awaiting_approval, rejected, failed, stopped. Use dispatch= instead of tools= to route tool calls yourself, for example through a governed, per-tenant dispatcher: dispatch(scope, name, arguments) must return a ToolResult. Any ragleap_agents state store works (InMemoryStateStore, SQLiteStateStore).

Multi-tenant rules

  1. Every call takes exactly a Scope. There is no unscoped run; single-tenant use is one fixed scope.
  2. A run records its scope key. resume continues it only for exactly that scope (every part). A wrong scope, an unknown run id and a damaged stored state all give the same ResumeError("unknown run"), and ownership is checked before any decision is read, so nobody learns that another tenant's run exists.
  3. Run ids are 128-bit random tokens.
  4. store_for(tenant) gives each tenant its own store. One shared store is safe because of the checks above, but anyone with access to the store file sees every tenant.
  5. Audit events (an AuditLog) hold the scope, ids, step ids, tool names and sizes, never input, arguments or results. If a record cannot be written, the error is raised and nothing continues.
  6. A rate_limiter (anything with check(scope)) is checked before a run starts or resumes.
  7. Taint, as in ragleap-agents: after a step marked "external": true, or for a run started with tainted=True, every later "outbound": true tool step pauses for approval first (pending["forced"] is true), each time.

Hard limits

100 steps per flow, 256 KiB flow file, 64 KiB input, 64 KiB per step output, 1 MiB saved state, 300 s deadline per run or resume call (checked between steps), no cycles, every step reachable, a path may only read a step that always runs before it. Each limit is refused or stopped with a named reason, never silently cut.

What this does not defend

  • It does not authenticate anybody. Pass only a Scope your application has established.
  • A tool that reads another tenant's data by itself is not stopped. Tools must be written tenant-safe, or called through a per-tenant dispatcher.
  • Approval is only as good as who is allowed to call resume. The library does not check who the approver is.
  • Taint only works if your flow marks external and outbound steps honestly. An unmarked step is trusted.
  • The deadline is checked between steps; a single slow tool call is not interrupted.
  • A run that crashes while running stays running; 0.1.0 does not recover it automatically.
  • One shared store file shows every tenant to whoever can read it; the state is not encrypted.
  • Not tested on Windows or macOS, network file systems, or several processes sharing one store beyond the atomic claim.
  • No independent security review.

Tests

153 tests; scripts/mutation_check.py breaks 68 protections one at a time and requires a test to fail. All 68 are caught. One more candidate was dropped as an equivalent mutant (the $$ check in parse_path is also enforced by the segment rule).

Metadata

Release files for ragleap-flows 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ragleap-flows 0.1.0
File Size Uploaded Provenance Actions
ragleap_flows-0.1.0.tar.gz 25.2 kB With provenance Details for ragleap_flows-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ragleap-flows 0.1.0
File Interpreter ABI Platform Actions
ragleap_flows-0.1.0-py3-none-any.whl Python 3 none any Details for ragleap_flows-0.1.0-py3-none-any.whl

Total release size: 39.3 kB

Release files / ragleap_flows-0.1.0.tar.gz

Download URL ragleap_flows-0.1.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
67ea4861d871a59fe5e765b472f2e9ba8edf4a6ec44e83c17ccc3bae18e987f7
BLAKE2b-256 checksum
How to use checksums
125f3cb0674d1a45f28f39ff0244fd2483ebb1fd255a047fce0043cde5de16bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / ragleap_flows-0.1.0-py3-none-any.whl

Download URL ragleap_flows-0.1.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b2d5c3a5d4364e6c52131dca8b5dd04fb2eb5eaf9e622b44699ba2964466375
BLAKE2b-256 checksum
How to use checksums
f3fb4e176998075284f5ac490a88a79fcaa068f361aea3f2fa73ea1b8c52cc32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for ragleap-flows 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ragleap_flows-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page