Skip to content

feat(plugins): add TealTiger deterministic governance guardrail - #1763

Open
nagasatish007 wants to merge 5 commits into
Portkey-AI:mainfrom
nagasatish007:main
Open

feat(plugins): add TealTiger deterministic governance guardrail#1763
nagasatish007 wants to merge 5 commits into
Portkey-AI:mainfrom
nagasatish007:main

Conversation

@nagasatish007

Copy link
Copy Markdown

Adds TealTiger as a native guardrails plugin for Portkey Gateway. Implements three guardrail functions:

  • PII Detection (beforeRequestHook / afterRequestHook) — scans prompts and responses for SSN, credit cards, emails, phone numbers, IBAN, and passport numbers using 40+ regex patterns
  • Secret Detection (beforeRequestHook / afterRequestHook) — detects API keys (OpenAI, AWS, GitHub, Slack), JWTs, private keys, and generic credentials
  • Cost Governance (beforeRequestHook) — estimates request cost and blocks if it exceeds configured per-request budget

All evaluation is deterministic (regex + policy rules) — no external API calls, no LLM in the governance path, under 2ms per check.

Closes #1688

Architecture

plugins/tealtiger/
├── manifest.json         # Plugin definition (3 guardrail functions)
├── piiDetection.ts       # PII scanning (SSN, CC, email, phone, IBAN, passport)
├── secretDetection.ts    # Secret/credential detection (7 pattern families)
└── costGovernance.ts     # Pre-dispatch cost estimation + budget enforcement

Key Design Decisions

  • No external dependency — all patterns are inline regex, no tealtiger npm package required. The plugin is self-contained.
  • Fail-open on error — if governance evaluation throws, the request passes through (safety default for a gateway)
  • Structured return data — every verdict includes governanceDecision, reasonCodes, riskScore, and evaluationEngine for downstream observability
  • No credentials required — the plugin runs entirely in-process with no API key needed

Testing

Each function can be tested with Portkey's standard plugin test setup:

  • PII: pass text with 123-45-6789 → expect verdict: false
  • Secret: pass text with sk-abcdefghij1234567890abcd → expect verdict: false
  • Cost: pass very long prompt with maxCostPerRequest: 0.001 → expect verdict: false

This file defines the TealTiger governance guardrail with functionalities for PII detection, secret detection, and cost governance, including detailed descriptions and parameters for each feature.
@nagasatish007

Copy link
Copy Markdown
Author

Hi @narengogi, please review . Thanks

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.

[Feature Request] TealTiger deterministic governance as a guardrails plugin

1 participant