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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sdf_plan-0.2.4-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sdf_plan-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 28.8 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1555f99a14727cdb9fdc2bbdd346025d863379b92c1bdd79c10248f6e63b9a89
MD5 e3ee9b277523ce1ed6064b910ee4fd93
BLAKE2b-256 697f3ac75aaad8a46af5eefea3f5db08ab9edb8eea764354cb3dea346b773d25

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdf_plan-0.2.4-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