Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"permissions": {
"allow": [
"Bash(git status:*)",
"Bash(git log:*)",
"Bash(git diff:*)",
"Bash(git branch:*)",
"Bash(ls:*)",
"Bash(find:*)",
"Bash(make lint:*)",
"Bash(make fmt:*)",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this one doesn't exist anymore

"Bash(pre-commit run:*)",
"Bash(uv run pytest:*)",
"Bash(uv run ruff:*)"
]
}
}
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ repos:
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: local
hooks:
- id: commit-msg-dco
name: DCO sign-off check
language: script
entry: scripts/hooks/commit-msg
stages: [commit-msg]
61 changes: 61 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# plugins-adapter

## Overview

An Envoy external processor (ext-proc) for configuring and invoking guardrails
in an Envoy-based gateway like [MCP Gateway](https://github.com/kagenti/mcp-gateway).
Intercepts gRPC traffic and applies configurable plugins (e.g., NeMo Guardrails).

## Repository Structure

```
plugins-adapter/
├── src/ # Core server implementation (ext-proc gRPC server)
├── plugins/ # Plugin implementations
│ └── examples/ # Example plugins (nemocheck, etc.)
├── tests/ # Unit tests (pytest)
├── docs/ # Architecture, build, deployment docs
├── resources/ # Kubernetes manifests and config
├── proto-build.sh # Protobuf code generation script
├── ext-proc.yaml # Envoy ExtProc deployment manifest
└── filter.yaml # Envoy HTTP filter config
```

## Key Commands

| Task | Command |
|------|---------|
| Lint + Format | `make lint` |
| Test | `uv run pytest tests/ -v` |
| Build image | `make build PLUGIN_DEPS=nemocheck` |
| Deploy to Kind | `make all PLUGIN_DEPS=nemocheck` |
| Build protobufs | `uv sync --group proto && ./proto-build.sh` |
| Run locally | `make dev-run-nemocheck` |

## Code Style

- Python 3.11+ with `uv` package manager
- Linter/formatter: `ruff` (config in `pyproject.toml`)
- Pre-commit hooks: `pre-commit install`
- Sign-off required: `git commit -s`

## Plugin Development

Plugins live in `plugins/`. Each plugin implements the `cpex` interface.
See `plugins/examples/` for reference implementations.

Config in `resources/config/config.yaml`:
```yaml
plugins:
- name: my_plugin
path: ./plugins/my_plugin
enabled: true
```

## DCO Sign-Off (Mandatory)

All commits must include a `Signed-off-by` trailer:

```sh
git commit -s -m "feat: add feature"
```
22 changes: 22 additions & 0 deletions scripts/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# commit-msg hook: enforce DCO sign-off and block Co-Authored-By AI attribution
set -euo pipefail

COMMIT_MSG_FILE="$1"
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")

# Check for DCO sign-off
if ! grep -qE "^Signed-off-by: .+ <.+@.+>" "$COMMIT_MSG_FILE"; then
echo "ERROR: Commit message missing Signed-off-by trailer (DCO required)."
echo " Use: git commit -s"
exit 1
fi

# Block Co-Authored-By for AI (use Assisted-By instead)
if grep -qiE "^Co-[Aa]uthored-[Bb]y:.*claude|^Co-[Aa]uthored-[Bb]y:.*anthropic|^Co-[Aa]uthored-[Bb]y:.*openai|^Co-[Aa]uthored-[Bb]y:.*chatgpt" "$COMMIT_MSG_FILE"; then
echo "ERROR: Use 'Assisted-By' instead of 'Co-Authored-By' for AI attribution."
echo " Replace with: Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>"
exit 1
fi

exit 0
Loading