Skip to content

feat: add hdp-crewai Python middleware package#5

Merged
asiridalugoda merged 1 commit intomainfrom
feat/hdp-crewai-package
Mar 27, 2026
Merged

feat: add hdp-crewai Python middleware package#5
asiridalugoda merged 1 commit intomainfrom
feat/hdp-crewai-package

Conversation

@asiridalugoda
Copy link
Copy Markdown
Contributor

Summary

Adds packages/hdp-crewai — a Python middleware package that attaches HDP delegation provenance to any CrewAI crew with zero changes to CrewAI core.

What's included

packages/hdp-crewai/
├── pyproject.toml
├── src/hdp_crewai/
│   ├── __init__.py       ← public API
│   ├── _types.py         ← HdpPrincipal, HdpToken, HopRecord, DataClassification
│   ├── _crypto.py        ← Ed25519 sign + verify (RFC 8785 canonical JSON)
│   ├── middleware.py     ← HdpMiddleware, ScopePolicy, HDPScopeViolationError
│   └── verify.py         ← verify_chain(), VerificationResult, HopVerification
└── tests/
    └── test_middleware.py  ← 26 tests, all passing

Five design considerations

# Consideration Implementation
1 Scope enforcement step_callback checks AgentAction.tool against authorized_tools; strict=True raises HDPScopeViolationError, default logs + records in token
2 Delegation depth max_hops enforced in task_callback; hops beyond limit are skipped
3 Token size / perf Ed25519 = 64 bytes/hop; all operations non-blocking
4 Verification verify_chain(token, public_key) validates chain offline
5 Memory integration Token persisted to CrewAI's db_storage_path() after kickoff

Related

Introduces packages/hdp-crewai — a non-blocking CrewAI integration
that attaches HDP delegation provenance to any crew with zero changes
to core CrewAI logic.

Hooks into CrewAI's existing callback system (before_kickoff_callbacks,
step_callback, task_callback, after_kickoff_callbacks) and implements
all five design considerations:

  1. Scope enforcement — step_callback inspects AgentAction.tool against
     authorized_tools; strict mode raises HDPScopeViolationError, default
     mode logs and records the violation in the token audit trail.
  2. Delegation depth limits — max_hops enforced per crew execution;
     hops beyond the limit are skipped and warned.
  3. Token size / performance — Ed25519 = 64 bytes/hop; all HDP
     operations are non-blocking (failures log, never raise).
  4. Verification utilities — verify_chain() validates the complete
     delegation chain offline using only the human's Ed25519 public key.
  5. Memory integration — after_kickoff persists the signed token JSON
     to CrewAI's storage directory alongside task outputs.

26 tests, all passing.
@asiridalugoda asiridalugoda merged commit da577cc into main Mar 27, 2026
2 checks passed
asiridalugoda added a commit that referenced this pull request Mar 27, 2026
Pins all ReleaseGuard usages to e3b02c8 rather than @main to prevent
auto-updating to a potentially compromised future version.

To upgrade: verify the new commit, then update the SHA here.
  ReleaseGuard@e3b02c8 — Merge PR #5 fix/upload-hidden-evidence-dir (2026-03-25)
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