Skip to main content

PlanSpec + lint + safety gates for agent plans.

Project description

sdf-plan

Tool safety gates for agent workflows.

30-Second Quickstart (ToolGate-first)

from sdf_plan import confirm, propose

first = propose(
    tool_name="filesystem.write",
    args={"path": "/tmp/demo.txt", "content": "hello"},
    meta={"workspace_id": "demo-ws"},
    run_context={"workspace_id": "demo-ws"},
)
print(first.decision.value)  # BLOCK

token = first.resume.token
_ = confirm(token, user_ok=True)

second = propose(
    tool_name="filesystem.write",
    args={"path": "/tmp/demo.txt", "content": "hello"},
    meta={"workspace_id": "demo-ws", "confirmed_token": token},
    run_context={"workspace_id": "demo-ws"},
)
print(second.decision.value)  # ALLOW

Expected flow: BLOCKED -> CONFIRM -> CONTINUE

Install

pip install sdf-plan

5-Minute First Success

python examples/tool_gate_quickstart.py
python examples/tool_gate_openai_input.py
python examples/plan_mode_preflight.py

What You Get

  • ToolGate runtime decisions (ALLOW | WARN | BLOCK)
  • Signed confirmation tokens + resume flow
  • Idempotency key derivation from scope + tool + canonical args
  • Tool-mode lint rules + policy defaults
  • PlanSpec lint and preflight (optional mode)
  • LangGraph adapter (official thin wrapper)

Optional PlanSpec Mode

Plan mode remains supported for existing users.

from sdf_plan import lint_plan, policy_annotate, preflight_lint

plan = {
    "steps": [
        {
            "id": "S1",
            "type": "ACT",
            "title": "send email",
            "intent": "send email",
            "inputs": [],
            "outputs": ["ctx.sent"],
            "depends_on": [],
            "stop_condition": "Step S1 completed",
            "fallback": "reduce_scope",
            "idempotency_key": "idem-1",
        }
    ]
}
plan, summary = policy_annotate(plan)
findings = lint_plan(plan, max_steps=12, safety_mode="safe")
preflight_lint(plan, max_steps=12, safety_mode="safe")

Guides

  • docs/ADAPTER_TEMPLATE.md
  • docs/POLICY_TUNING.md
  • docs/TOOL_CLASSIFICATION.md
  • docs/COMPATIBILITY.md

Examples

  • examples/tool_gate_quickstart.py
  • examples/tool_gate_openai_input.py
  • examples/plan_mode_preflight.py
  • examples/adapter_minimal.py
  • examples/langgraph_plangate_demo.py
  • examples/crewai_plangate_demo.py

Compatibility

Use Cloud schema hash checks to detect contract drift:

from sdf_plan.compat import assert_schema_compat, package_version

assert_schema_compat(package_version(), "schema_hash_from_/v1/schema")

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

sdf_plan-0.2.6.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

sdf_plan-0.2.6-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file sdf_plan-0.2.6.tar.gz.

File metadata

  • Download URL: sdf_plan-0.2.6.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sdf_plan-0.2.6.tar.gz
Algorithm Hash digest
SHA256 59e8fc7f54ea2881a740bfba4d2da15e56e2aa150d8ce6e700627a48c1b97e62
MD5 a464961ec815b0741f0b6a62fe179f35
BLAKE2b-256 57ceee3965d0ee1e297c418c3d0a08bebdcc6eadeecd44a383d625de818e590f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_plan-0.2.6.tar.gz:

Publisher: release.yml on directiveproto/sdf-plan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdf_plan-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: sdf_plan-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sdf_plan-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 092ef08f1807631ee577c4a07bfb627c140072dc8db4805ca63a841c68ddbc01
MD5 d9d14e86795137f6d4658ac5149e2275
BLAKE2b-256 006342b2e22ac2f700fd23b8da112b34d126ab7fdb71f4a076de50f0e00a3180

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_plan-0.2.6-py3-none-any.whl:

Publisher: release.yml on directiveproto/sdf-plan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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