Skip to content

feat(tools): add SignatrustTool for AI Decision Receipts#6369

Open
abokenan444 wants to merge 3 commits into
crewAIInc:mainfrom
abokenan444:add-signatrust-tool
Open

feat(tools): add SignatrustTool for AI Decision Receipts#6369
abokenan444 wants to merge 3 commits into
crewAIInc:mainfrom
abokenan444:add-signatrust-tool

Conversation

@abokenan444

@abokenan444 abokenan444 commented Jun 27, 2026

Copy link
Copy Markdown

Overview

This PR adds SignatrustTool — a new tool that lets CrewAI agents generate, verify, and retrieve cryptographically signed AI Decision Receipts via Signatrust.

Signatrust produces tamper-evident, Ed25519-signed receipts for decisions made by AI agents, enabling verifiable accountability and auditability of AI-assisted decisions (compliance reviews, approvals, financial actions, content moderation, etc.). By default only a SHA-256 hash of the decision payload is stored server-side, so the tool is privacy-first.

What's included

  • crewai_tools/tools/signatrust_tool/signatrust_tool.py — the SignatrustTool implementation
  • crewai_tools/tools/signatrust_tool/README.md — usage docs and required env vars
  • tests/tools/signatrust_tool_test.py — 8 unit tests (no real network calls, all passing)
  • Registration in crewai_tools/tools/__init__.py and crewai_tools/__init__.py
  • tool.specs.json entry (generated via generate_tool_specs.py)

Supported operations

  • generate — create a new signed Decision Receipt for an agent decision
  • verify — verify the cryptographic integrity of an existing receipt by id
  • get — retrieve a stored receipt by id

Conventions followed (per BUILDING_TOOLS.md)

  • Class name ends with Tool and subclasses BaseTool
  • Pydantic args_schema with explicit field descriptions
  • env_vars (SIGNATRUST_API_KEY) and package_dependencies declared
  • Lazy dependency handling and clear, actionable error messages
  • Deterministic, compact output (JSON string)
  • Unit tests under tests/tools/, fast and deterministic

Required environment variables

Variable Required Description
SIGNATRUST_API_KEY Yes Signatrust API key (sk_live_...)

Notes

A standalone package (crewai-signatrust) is also published on PyPI; this PR brings the integration into the official crewai-tools collection for discoverability.

Summary by CodeRabbit

  • New Features
    • Added a Signatrust Decision Receipt tool to generate, verify, and retrieve signed receipts.
    • Exposed the tool at the top-level package and the tools module.
    • Added a formal tool specification to standardize configuration and inputs/outputs.
  • Documentation
    • Added setup and usage instructions, including required configuration and example calls.
  • Tests
    • Added coverage for initialization behavior, HTTP handling for all operations, async execution, and key error scenarios.

Add SignatrustTool, a BaseTool wrapper around the Signatrust REST API that
lets CrewAI agents generate, verify, and retrieve cryptographically signed
(Ed25519) AI Decision Receipts — tamper-evident records of agent decisions.

- Self-contained tool (no extra runtime deps beyond 'requests')
- Declares SIGNATRUST_API_KEY via EnvVar and 'requests' via package_dependencies
- Registered in tools/__init__.py and root __init__.py
- Regenerated tool.specs.json (single new entry)
- 8 unit tests covering init, generate, verify, get, and error paths
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d6b6758-8141-435f-ab59-cacd5c0ae475

📥 Commits

Reviewing files that changed from the base of the PR and between 7aae86f and 5cc9a3d.

📒 Files selected for processing (1)
  • lib/crewai-tools/tests/tools/signatrust_tool_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/crewai-tools/tests/tools/signatrust_tool_test.py

📝 Walkthrough

Walkthrough

Adds a new SignatrustTool that wraps the Signatrust REST API to generate, verify, and retrieve cryptographically signed AI Decision Receipts. Includes the input schema, HTTP implementation, package exports, tool spec JSON entry, README, and tests.

Changes

SignatrustTool

Layer / File(s) Summary
Schema and implementation
lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py
Defines the SignatrustToolInput schema, SignatrustTool metadata, API-key setup, HTTP helpers, operation routing, and async delegation.
Test coverage
lib/crewai-tools/tests/tools/signatrust_tool_test.py
Adds fixture setup, constructor coverage, mocked generate/verify/get requests, error-message checks, async execution coverage, and deterministic JSON serialization assertions.
Exports, tool spec, and README
lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/__init__.py, lib/crewai-tools/tool.specs.json, lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/README.md
Registers SignatrustTool in both package export modules, adds the tool specification entry with init and run schemas, and adds the README documentation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding SignatrustTool for AI Decision Receipts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/crewai-tools/tests/tools/signatrust_tool_test.py (1)

32-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for _arun and output ordering.

The current suite only exercises .run(), so the async path and deterministic-JSON contract can regress unnoticed. One async test plus one assertion on stable key ordering would lock both down.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai-tools/tests/tools/signatrust_tool_test.py` around lines 32 - 90,
Add regression coverage in the Signatrust tool tests for the async path and
deterministic JSON output: extend the existing `signatrust_tool` test suite so
`_arun` is exercised alongside `run()`, and add an assertion that the serialized
response preserves stable key ordering. Use the existing `test_generate`,
`test_verify`, and `test_get` patterns in `signatrust_tool_test.py` to locate
where to add the async test and the JSON-order check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py`:
- Line 202: The success payload serialization in SignatrustTool is
non-deterministic because json.dumps(result, ensure_ascii=False) preserves
upstream key order; update the return path in SignatrustTool so the serialized
response is stable across equivalent receipts by normalizing the data before
serialization and using a deterministic ordering strategy. Keep the fix local to
the method that returns result, and ensure the output remains valid JSON while
producing the same string for semantically identical payloads.
- Around line 206-208: The _arun method in SignaTrustTool is still calling the
blocking _run path directly, which stalls the event loop for async callers.
Update _arun in signatrust_tool to offload the synchronous _run call to a worker
thread or add a true async client implementation, keeping the async entrypoint
non-blocking while preserving the existing _run logic.

---

Nitpick comments:
In `@lib/crewai-tools/tests/tools/signatrust_tool_test.py`:
- Around line 32-90: Add regression coverage in the Signatrust tool tests for
the async path and deterministic JSON output: extend the existing
`signatrust_tool` test suite so `_arun` is exercised alongside `run()`, and add
an assertion that the serialized response preserves stable key ordering. Use the
existing `test_generate`, `test_verify`, and `test_get` patterns in
`signatrust_tool_test.py` to locate where to add the async test and the
JSON-order check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4bcb778a-651f-4827-8208-b7bdb4a5e30e

📥 Commits

Reviewing files that changed from the base of the PR and between 6491f5a and 4935e91.

📒 Files selected for processing (7)
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py
  • lib/crewai-tools/tests/tools/signatrust_tool_test.py
  • lib/crewai-tools/tool.specs.json

Comment thread lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py Outdated
Comment thread lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py Outdated
Addresses CodeRabbit review on PR crewAIInc#6369:

- json.dumps(..., sort_keys=True) so equivalent receipts always serialize to the same string.

- _arun now offloads _run to asyncio.to_thread instead of blocking the event loop.

- Add regression tests for both behaviors.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/crewai-tools/tests/tools/signatrust_tool_test.py`:
- Around line 95-112: The test for SignatrustTool._arun currently only checks
the returned payload and does not prove the blocking HTTP call is offloaded;
update test_arun_non_blocking to assert worker-thread execution or event-loop
responsiveness. Use the existing _arun and mock_post setup to capture the thread
identity inside the mocked request path, then verify it differs from the main
thread (or otherwise confirm the loop can keep running while the call is in
progress) so the test fails if _arun regresses to delegating directly to _run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dff9b606-c178-44cf-a72e-ae55b56ab158

📥 Commits

Reviewing files that changed from the base of the PR and between 4935e91 and 7aae86f.

📒 Files selected for processing (2)
  • lib/crewai-tools/src/crewai_tools/tools/signatrust_tool/signatrust_tool.py
  • lib/crewai-tools/tests/tools/signatrust_tool_test.py

Comment thread lib/crewai-tools/tests/tools/signatrust_tool_test.py
Address CodeRabbit review: prior test_arun_non_blocking only checked the payload and would pass even if _arun regressed to `return self._run(**kwargs)`. Capture threading.get_ident() inside the mock_post side_effect and assert it differs from the main thread id, proving the blocking HTTP call is dispatched via asyncio.to_thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant