Skip to content
Merged
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
49 changes: 49 additions & 0 deletions .github/workflows/lexshield-check.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Example workflow: validate policy packs in CI.
# Copy to .github/workflows/lexshield-check.yml once the CLI is published.

name: LexShield Policy Check

on:
push:
branches: [main]
paths:
- "packs/**"
- "schemas/**"
- "lexshield.yaml"
- "policy.yaml"
- "rules.yaml"
pull_request:
paths:
- "packs/**"
- "schemas/**"
- "lexshield.yaml"
- "policy.yaml"
- "rules.yaml"

jobs:
lexshield-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install LexShield CLI
run: pip install lexshield

- name: Validate shipped policy packs
run: |
for pack in baseline-deny pii-guard change-window; do
echo "Checking pack: $pack"
lexshield check \
--policy "packs/${pack}/policy.yaml" \
--rules "packs/${pack}/rules.yaml" \
--strict
done

- name: Validate root policy (if present)
if: hashFiles('lexshield.yaml') != ''
run: lexshield check --strict
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# LexShield local state
.lexshield/
traces.ndjson

# Accidental init at repo root during development
/lexshield.yaml
/policy.yaml
/rules.yaml

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
.venv/
venv/
ENV/
env/
*.egg-info/
.eggs/
dist/
build/
*.egg
.pytest_cache/
.mypy_cache/
.ruff_cache/
.coverage
htmlcov/
.tox/
.nox/
pip-wheel-metadata/
*.manifest
*.spec

# uv
.uv/
uv.lock

# Node / pnpm
node_modules/
.pnpm-store/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
*.tsbuildinfo

# Build outputs
dist/
out/
lib/
coverage/

# IDE / OS
.idea/
.vscode/
*.swp
*.swo
*~
.DS_Store
Thumbs.db

# Environment
.env
.env.*
!.env.example

# Test / tooling artifacts
.hypothesis/
.pytest_cache/
vitest.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 LatticeAG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LexShield
Copyright (c) 2026 LatticeAG

This product includes software developed by LatticeAG (https://latticeag.com).

LexShield is distributed under the MIT License. See LICENSE for the full text.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# LexShield

**The open-source policy firewall for agent tool calls.**

LexShield sits between an AI agent and its tool fleet, classifies the intent behind each tool call, and enforces allow/block/challenge policy **before** execution. Fully local-first — no SaaS required.

- **License**: MIT
- **Publisher**: [LatticeAG](https://latticeag.com)
- **Specification**: see [SPEC.md](./SPEC.md) for product scope, APIs, and v0.1 feature freeze

## Quickstart (5 minutes, deterministic-only)

No API key required for the deterministic path.

```bash
# Install (PyPI — coming soon)
pip install lexshield

# Scaffold config + baseline policy pack
lexshield init --pack baseline-deny

# Validate policy
lexshield check

# Evaluate a tool call offline
lexshield evaluate --tool send_email --args '{"to":"user@example.com","body":"AKIA0123456789012345"}' --json
# → BLOCK (security.secret_exposure)

# Allow a health check
lexshield evaluate --tool health_check --args '{}' --json
# → ALLOW
```

### Path outline

1. **Install** — `pip install lexshield` (Python SDK + CLI)
2. **Init** — `lexshield init` writes `lexshield.yaml`, `policy.yaml`, `rules.yaml`
3. **Check** — `lexshield check` validates policy in CI (exit non-zero on errors)
4. **Evaluate** — `lexshield evaluate` or `Shield.guard` decorator before tool execution
5. **Trace** — verdicts append to `traces.ndjson` for audit

For TypeScript: `npm install @latticeag/lexshield` (evaluate + guard parity).

## Monorepo layout

| Package | Path | Role |
|---------|------|------|
| Python engine | `packages/engine-py` | Policy engine, classifiers (source of truth) |
| Python CLI | `packages/cli` | `lexshield` Typer CLI |
| TypeScript SDK | `packages/engine-ts` | `@latticeag/lexshield` evaluate/guard |

## Development

```bash
# Python (uv workspace)
uv sync
uv run pytest

# TypeScript (pnpm workspace)
pnpm install
pnpm -r test
```

See [SPEC.md](./SPEC.md) for architecture, policy language, intent taxonomy, and acceptance criteria.
Loading
Loading