governed 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- governed-0.1.0/.github/dependabot.yml +14 -0
- governed-0.1.0/.github/workflows/ci.yml +97 -0
- governed-0.1.0/.github/workflows/release.yml +51 -0
- governed-0.1.0/.gitignore +24 -0
- governed-0.1.0/CODE_OF_CONDUCT.md +131 -0
- governed-0.1.0/CONTRIBUTING.md +131 -0
- governed-0.1.0/LICENSE +202 -0
- governed-0.1.0/PKG-INFO +1608 -0
- governed-0.1.0/README.md +1559 -0
- governed-0.1.0/SECURITY.md +75 -0
- governed-0.1.0/docs/GUIDE.md +410 -0
- governed-0.1.0/docs/RESPONSIBLE_AI.md +751 -0
- governed-0.1.0/docs/ROADMAP.md +160 -0
- governed-0.1.0/examples/01_basic.py +50 -0
- governed-0.1.0/examples/02_custom_tool.py +152 -0
- governed-0.1.0/examples/03_offline_scripted.py +153 -0
- governed-0.1.0/examples/04_guardrails_and_cost.py +186 -0
- governed-0.1.0/examples/05_config_driven.py +235 -0
- governed-0.1.0/pyproject.toml +91 -0
- governed-0.1.0/skills/csv_profiling/SKILL.md +43 -0
- governed-0.1.0/skills/incident_summary/SKILL.md +48 -0
- governed-0.1.0/skills/safe_code_change/SKILL.md +50 -0
- governed-0.1.0/src/governed/__init__.py +337 -0
- governed-0.1.0/src/governed/agent.py +1089 -0
- governed-0.1.0/src/governed/bootstrap.py +436 -0
- governed-0.1.0/src/governed/cli.py +144 -0
- governed-0.1.0/src/governed/config.py +266 -0
- governed-0.1.0/src/governed/contracts.py +229 -0
- governed-0.1.0/src/governed/llm/__init__.py +49 -0
- governed-0.1.0/src/governed/llm/anthropic_client.py +127 -0
- governed-0.1.0/src/governed/llm/base.py +103 -0
- governed-0.1.0/src/governed/llm/config.py +31 -0
- governed-0.1.0/src/governed/llm/factory.py +100 -0
- governed-0.1.0/src/governed/llm/gemini_client.py +154 -0
- governed-0.1.0/src/governed/llm/openai_client.py +122 -0
- governed-0.1.0/src/governed/llm/policy.py +58 -0
- governed-0.1.0/src/governed/llm/scripted.py +51 -0
- governed-0.1.0/src/governed/memory/__init__.py +52 -0
- governed-0.1.0/src/governed/memory/optimizer.py +631 -0
- governed-0.1.0/src/governed/memory/session.py +235 -0
- governed-0.1.0/src/governed/memory/store.py +71 -0
- governed-0.1.0/src/governed/memory/transcript.py +137 -0
- governed-0.1.0/src/governed/observability/__init__.py +89 -0
- governed-0.1.0/src/governed/observability/audit.py +201 -0
- governed-0.1.0/src/governed/observability/decision_ledger.py +461 -0
- governed-0.1.0/src/governed/observability/events.py +97 -0
- governed-0.1.0/src/governed/observability/exporters.py +95 -0
- governed-0.1.0/src/governed/observability/logger.py +349 -0
- governed-0.1.0/src/governed/observability/telemetry.py +438 -0
- governed-0.1.0/src/governed/prompts/__init__.py +21 -0
- governed-0.1.0/src/governed/prompts/system.py +154 -0
- governed-0.1.0/src/governed/security/__init__.py +86 -0
- governed-0.1.0/src/governed/security/content_safety.py +333 -0
- governed-0.1.0/src/governed/security/guardrails.py +1408 -0
- governed-0.1.0/src/governed/security/policy.py +139 -0
- governed-0.1.0/src/governed/skills/__init__.py +21 -0
- governed-0.1.0/src/governed/skills/loader.py +230 -0
- governed-0.1.0/src/governed/tools/__init__.py +181 -0
- governed-0.1.0/src/governed/tools/base.py +244 -0
- governed-0.1.0/src/governed/tools/code_execution.py +339 -0
- governed-0.1.0/src/governed/tools/control.py +179 -0
- governed-0.1.0/src/governed/tools/data_analysis.py +182 -0
- governed-0.1.0/src/governed/tools/errors.py +90 -0
- governed-0.1.0/src/governed/tools/filesystem.py +145 -0
- governed-0.1.0/src/governed/tools/registry.py +170 -0
- governed-0.1.0/tests/conftest.py +19 -0
- governed-0.1.0/tests/test_agent.py +172 -0
- governed-0.1.0/tests/test_bootstrap.py +247 -0
- governed-0.1.0/tests/test_cancellation.py +303 -0
- governed-0.1.0/tests/test_cli.py +185 -0
- governed-0.1.0/tests/test_code_execution.py +257 -0
- governed-0.1.0/tests/test_config_composition.py +299 -0
- governed-0.1.0/tests/test_content_safety.py +465 -0
- governed-0.1.0/tests/test_contracts.py +135 -0
- governed-0.1.0/tests/test_data_analysis.py +202 -0
- governed-0.1.0/tests/test_decision_ledger.py +508 -0
- governed-0.1.0/tests/test_gemini_client.py +316 -0
- governed-0.1.0/tests/test_governance.py +328 -0
- governed-0.1.0/tests/test_guardrails.py +410 -0
- governed-0.1.0/tests/test_llm_factory.py +240 -0
- governed-0.1.0/tests/test_monitoring_exporters.py +257 -0
- governed-0.1.0/tests/test_optimizer.py +419 -0
- governed-0.1.0/tests/test_plugin_registries.py +274 -0
- governed-0.1.0/tests/test_skills.py +39 -0
- governed-0.1.0/tests/test_telemetry.py +346 -0
- governed-0.1.0/tests/test_tools.py +132 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Runtime and optional-provider dependencies declared in pyproject.toml.
|
|
4
|
+
- package-ecosystem: "pip"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
open-pull-requests-limit: 10
|
|
9
|
+
|
|
10
|
+
# Actions pinned in .github/workflows/*.yml (actions/checkout, setup-python).
|
|
11
|
+
- package-ecosystem: "github-actions"
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: "weekly"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
# A second push to the same branch/PR cancels the still-running check for the
|
|
9
|
+
# previous one -- no point finishing a lint run for a commit that's already
|
|
10
|
+
# been superseded.
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
name: Python ${{ matrix.python-version }}
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
cache: pip
|
|
32
|
+
|
|
33
|
+
- name: Install (core + dev + all optional providers)
|
|
34
|
+
run: pip install -e '.[dev]'
|
|
35
|
+
|
|
36
|
+
# Every check below is exactly what README's "Contributing" section
|
|
37
|
+
# asks a human to run before submitting -- CI just enforces it.
|
|
38
|
+
- name: Lint (ruff check)
|
|
39
|
+
run: ruff check .
|
|
40
|
+
|
|
41
|
+
- name: Format check (ruff format)
|
|
42
|
+
run: ruff format --check .
|
|
43
|
+
|
|
44
|
+
- name: Type-check (mypy --strict, src only)
|
|
45
|
+
run: mypy src
|
|
46
|
+
|
|
47
|
+
# --cov turns on coverage measurement and, via [tool.coverage.report]
|
|
48
|
+
# fail_under in pyproject.toml, gates on it -- plain `pytest` (every
|
|
49
|
+
# local run, per CONTRIBUTING.md) has no coverage overhead and isn't
|
|
50
|
+
# gated at all; only this explicit, full-suite CI invocation is.
|
|
51
|
+
- name: Test (offline -- no network, no API key)
|
|
52
|
+
run: pytest --cov=governed --cov-report=term-missing
|
|
53
|
+
|
|
54
|
+
dependency-audit:
|
|
55
|
+
name: Dependency & supply-chain audit
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v4
|
|
60
|
+
|
|
61
|
+
- name: Set up Python
|
|
62
|
+
uses: actions/setup-python@v5
|
|
63
|
+
with:
|
|
64
|
+
python-version: "3.12"
|
|
65
|
+
cache: pip
|
|
66
|
+
|
|
67
|
+
# pip itself ships with the runner image and is often behind -- audit
|
|
68
|
+
# it too, but upgrade first so a stale *pip* CVE doesn't fail the job
|
|
69
|
+
# for a package governed doesn't even declare a dependency on.
|
|
70
|
+
- name: Upgrade pip
|
|
71
|
+
run: pip install --upgrade pip
|
|
72
|
+
|
|
73
|
+
# Audits the full dependency tree governed can pull in -- core plus
|
|
74
|
+
# every optional provider/extra -- not just what a bare install
|
|
75
|
+
# resolves, since [all]'s pins are what most deployments actually run.
|
|
76
|
+
- name: Install (core + all optional providers, no dev tooling)
|
|
77
|
+
run: pip install -e '.[all]' pip-audit cyclonedx-bom
|
|
78
|
+
|
|
79
|
+
- name: Audit installed dependencies for known vulnerabilities
|
|
80
|
+
run: pip-audit --strict
|
|
81
|
+
|
|
82
|
+
# A framework whose pitch is auditability should be able to answer
|
|
83
|
+
# "what's actually in this build" for itself -- a CycloneDX SBOM of
|
|
84
|
+
# the exact environment `[all]` resolves to, attached to the run so
|
|
85
|
+
# it's inspectable (and diffable, run to run) without reproducing the
|
|
86
|
+
# install locally.
|
|
87
|
+
- name: Generate SBOM (CycloneDX)
|
|
88
|
+
run: |
|
|
89
|
+
cyclonedx-py environment --pyproject pyproject.toml \
|
|
90
|
+
--output-format JSON --output-file sbom.json "$(which python)"
|
|
91
|
+
|
|
92
|
+
- name: Upload SBOM
|
|
93
|
+
uses: actions/upload-artifact@v4
|
|
94
|
+
with:
|
|
95
|
+
name: sbom
|
|
96
|
+
path: sbom.json
|
|
97
|
+
retention-days: 90
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI on every tag matching v*.*.* (e.g. v0.2.0). Uses PyPI
|
|
4
|
+
# Trusted Publishing (OIDC) -- no API token stored in this repo. The PyPI
|
|
5
|
+
# project must have this repo/workflow registered as a trusted publisher
|
|
6
|
+
# first (see CONTRIBUTING.md / repo docs for the one-time setup).
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["v*.*.*"]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
name: Build sdist and wheel
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Install build
|
|
24
|
+
run: pip install --upgrade build
|
|
25
|
+
|
|
26
|
+
- name: Build
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Upload build artifacts
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
name: Publish to PyPI
|
|
37
|
+
needs: build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
environment: pypi
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write # required for OIDC trusted publishing
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Download build artifacts
|
|
45
|
+
uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist/
|
|
49
|
+
|
|
50
|
+
- name: Publish
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.egg-info/
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
# runtime artifacts from examples/tests
|
|
17
|
+
examples/workspace/
|
|
18
|
+
examples/traces/
|
|
19
|
+
examples/.agentloop/
|
|
20
|
+
workspace/
|
|
21
|
+
traces/
|
|
22
|
+
.agentloop/
|
|
23
|
+
|
|
24
|
+
.DS_Store
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic
|
|
9
|
+
status, nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment:
|
|
18
|
+
|
|
19
|
+
- Demonstrating empathy and kindness toward other people
|
|
20
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
21
|
+
- Giving and gracefully accepting constructive feedback
|
|
22
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
23
|
+
and learning from the experience
|
|
24
|
+
- Focusing on what is best not just for us as individuals, but for the
|
|
25
|
+
overall community
|
|
26
|
+
|
|
27
|
+
Examples of unacceptable behavior:
|
|
28
|
+
|
|
29
|
+
- The use of sexualized language or imagery, and sexual attention or
|
|
30
|
+
advances of any kind
|
|
31
|
+
- Trolling, insulting or derogatory comments, and personal or political
|
|
32
|
+
attacks
|
|
33
|
+
- Public or private harassment
|
|
34
|
+
- Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Project maintainers are responsible for clarifying and enforcing our
|
|
42
|
+
standards of acceptable behavior and will take appropriate and fair
|
|
43
|
+
corrective action in response to any behavior they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
Maintainers have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned with this Code of Conduct, and will communicate reasons for
|
|
49
|
+
moderation decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces (issues, pull
|
|
54
|
+
requests, discussions, and any other governed-affiliated forum), and also
|
|
55
|
+
applies when an individual is officially representing the community in
|
|
56
|
+
public spaces.
|
|
57
|
+
|
|
58
|
+
## Enforcement
|
|
59
|
+
|
|
60
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
61
|
+
reported to the project maintainers via GitHub's private reporting channel
|
|
62
|
+
for this repository (see the Security tab, or open an issue asking for a
|
|
63
|
+
private channel — the same route [`SECURITY.md`](SECURITY.md) uses for
|
|
64
|
+
vulnerabilities not suited to a public issue). All complaints will be
|
|
65
|
+
reviewed and investigated promptly and fairly.
|
|
66
|
+
|
|
67
|
+
All maintainers are obligated to respect the privacy and security of the
|
|
68
|
+
reporter of any incident.
|
|
69
|
+
|
|
70
|
+
## Enforcement Guidelines
|
|
71
|
+
|
|
72
|
+
Maintainers will follow these Community Impact Guidelines in determining the
|
|
73
|
+
consequences for any action they deem in violation of this Code of Conduct:
|
|
74
|
+
|
|
75
|
+
### 1. Correction
|
|
76
|
+
|
|
77
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
78
|
+
unprofessional or unwelcome in the community.
|
|
79
|
+
|
|
80
|
+
**Consequence**: A private, written warning, providing clarity around the
|
|
81
|
+
nature of the violation and an explanation of why the behavior was
|
|
82
|
+
inappropriate. A public apology may be requested.
|
|
83
|
+
|
|
84
|
+
### 2. Warning
|
|
85
|
+
|
|
86
|
+
**Community Impact**: A violation through a single incident or series of
|
|
87
|
+
actions.
|
|
88
|
+
|
|
89
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
90
|
+
interaction with the people involved for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external
|
|
92
|
+
channels. Violating these terms may lead to a temporary or permanent ban.
|
|
93
|
+
|
|
94
|
+
### 3. Temporary Ban
|
|
95
|
+
|
|
96
|
+
**Community Impact**: A serious violation of community standards, including
|
|
97
|
+
sustained inappropriate behavior.
|
|
98
|
+
|
|
99
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
100
|
+
communication with the community for a specified period of time. No public
|
|
101
|
+
or private interaction with the people involved is allowed during this
|
|
102
|
+
period. Violating these terms may lead to a permanent ban.
|
|
103
|
+
|
|
104
|
+
### 4. Permanent Ban
|
|
105
|
+
|
|
106
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
107
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
108
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
109
|
+
|
|
110
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
111
|
+
the community.
|
|
112
|
+
|
|
113
|
+
## Attribution
|
|
114
|
+
|
|
115
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
116
|
+
version 2.1, available at
|
|
117
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
118
|
+
|
|
119
|
+
Community Impact Guidelines were inspired by
|
|
120
|
+
[Mozilla's code of conduct enforcement ladder][mozilla].
|
|
121
|
+
|
|
122
|
+
[homepage]: https://www.contributor-covenant.org
|
|
123
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
124
|
+
[mozilla]: https://github.com/mozilla/diversity
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
[https://www.contributor-covenant.org/faq][faq]. Translations are available
|
|
128
|
+
at [https://www.contributor-covenant.org/translations][translations].
|
|
129
|
+
|
|
130
|
+
[faq]: https://www.contributor-covenant.org/faq
|
|
131
|
+
[translations]: https://www.contributor-covenant.org/translations
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Contributing to governed
|
|
2
|
+
|
|
3
|
+
Issues and PRs welcome. This document is the practical how-to; the
|
|
4
|
+
[README](README.md) is the reference for what the framework does and why it's
|
|
5
|
+
built the way it is — read that first if you're touching unfamiliar code,
|
|
6
|
+
since most non-obvious design choices here are argued for there, not repeated
|
|
7
|
+
in this file.
|
|
8
|
+
|
|
9
|
+
Found a security vulnerability rather than a bug? See
|
|
10
|
+
[SECURITY.md](SECURITY.md) instead of opening a public issue or PR.
|
|
11
|
+
|
|
12
|
+
Participation in this project — issues, PRs, discussions — is governed by the
|
|
13
|
+
[Code of Conduct](CODE_OF_CONDUCT.md).
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/poorani/governed && cd governed
|
|
19
|
+
pip install -e '.[dev]'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`[dev]` pulls in every optional provider extra (`anthropic`, `openai`,
|
|
23
|
+
`gemini`, `data`, `yaml`) plus `pytest`, `mypy`, and `ruff` — the same set CI
|
|
24
|
+
installs, so a clean local run means a clean CI run.
|
|
25
|
+
|
|
26
|
+
## Before opening a PR
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
ruff check . && ruff format --check .
|
|
30
|
+
mypy src
|
|
31
|
+
pytest
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
[`.github/workflows/ci.yml`](.github/workflows/ci.yml) runs exactly these
|
|
35
|
+
four checks on every push and PR, across Python 3.10/3.11/3.12. The whole
|
|
36
|
+
suite is offline — no network, no API keys, ever (see "Testing conventions"
|
|
37
|
+
below) — so there's no reason a local run and CI should disagree on whether
|
|
38
|
+
the tests pass.
|
|
39
|
+
|
|
40
|
+
CI's test step additionally runs with coverage measurement
|
|
41
|
+
(`pytest --cov=governed --cov-report=term-missing`), gated by
|
|
42
|
+
`fail_under` in `pyproject.toml`'s `[tool.coverage.report]` — currently 85%,
|
|
43
|
+
a floor below the actual total (~90%) on purpose, so it catches a genuinely
|
|
44
|
+
untested new module or code path, not everyday variance. Plain `pytest` (no
|
|
45
|
+
`--cov`) never measures or gates on coverage, so this doesn't slow down or
|
|
46
|
+
complicate the everyday local loop above; run
|
|
47
|
+
`pytest --cov=governed --cov-report=term-missing` yourself before a PR that
|
|
48
|
+
adds a new file or a large new code path, to see the same numbers CI will.
|
|
49
|
+
|
|
50
|
+
A separate `dependency-audit` job runs on the same triggers: `pip-audit`
|
|
51
|
+
against the full dependency tree (core plus every optional provider), and a
|
|
52
|
+
CycloneDX SBOM of the resolved environment, uploaded as a build artifact.
|
|
53
|
+
[Dependabot](.github/dependabot.yml) opens a PR weekly for anything outdated
|
|
54
|
+
or flagged, for both Python dependencies and the GitHub Actions themselves.
|
|
55
|
+
You don't need to run either locally; they don't gate on dependencies your
|
|
56
|
+
PR doesn't touch.
|
|
57
|
+
|
|
58
|
+
## Where new code goes
|
|
59
|
+
|
|
60
|
+
- **A new tool** belongs in `src/governed/tools/`, ships with tests, and
|
|
61
|
+
its docstring must justify why it isn't better served by `execute_code` —
|
|
62
|
+
see "Adding a tool" in the README for the shape (`name`/`description`/
|
|
63
|
+
`safety`/`Input`/`run`) and the guidelines that earn their keep
|
|
64
|
+
(`description` is written for the model, not your teammates; every error
|
|
65
|
+
gets a `remediation`; output is bounded).
|
|
66
|
+
- **A new skill** belongs in `skills/<name>/SKILL.md` and should encode
|
|
67
|
+
judgement, not syntax — "Writing a skill" in the README has the frontmatter
|
|
68
|
+
shape and what makes a skill worth shipping.
|
|
69
|
+
- **A new LLM provider, or anything else selectable by name from config**
|
|
70
|
+
(a tool, a skill source, a decision-ledger sink/store, an event sink, a
|
|
71
|
+
state store) almost always belongs behind the existing plugin-registry
|
|
72
|
+
pattern rather than a new core dependency or a new special case in
|
|
73
|
+
`bootstrap.py`. `register_provider`/`register_tool`/`register_skill_source`/
|
|
74
|
+
`register_event_sink`/`register_decision_ledger_sink`/
|
|
75
|
+
`register_decision_ledger_store`/`register_state_store` all follow the
|
|
76
|
+
same shape: a factory function, registered under a name, selectable from
|
|
77
|
+
data from then on. See "Plugin registries" in the README before adding a
|
|
78
|
+
vendor SDK to `pyproject.toml`'s core dependencies — the core has exactly
|
|
79
|
+
one (`pydantic`), and that's deliberate.
|
|
80
|
+
- **A new deterministic scanner** (in the shape of `InjectionScanner` /
|
|
81
|
+
`SecretExfiltrationScanner` / `PIIScanner`) belongs in
|
|
82
|
+
`security/guardrails.py`, subclassing `_RegexScanner`. State plainly, in
|
|
83
|
+
the docstring, what it does and doesn't catch — every scanner in this
|
|
84
|
+
codebase is upfront about being detection, not a boundary. If the change
|
|
85
|
+
touches guardrails, governance, the decision ledger, or approval flow,
|
|
86
|
+
update [`docs/RESPONSIBLE_AI.md`](docs/RESPONSIBLE_AI.md) too: it's the
|
|
87
|
+
one place that draws the line between what's structurally guaranteed and
|
|
88
|
+
what's detection, and a new scanner or toggle that isn't reflected there
|
|
89
|
+
is a documentation regression, not just a missing docstring.
|
|
90
|
+
|
|
91
|
+
## Testing conventions
|
|
92
|
+
|
|
93
|
+
No test may require network access or a real API key. The two seams that
|
|
94
|
+
make this possible, used throughout:
|
|
95
|
+
|
|
96
|
+
- **`ScriptedClient`** (`governed.llm`) for anything exercising the agent
|
|
97
|
+
loop end-to-end — hand it a scripted sequence of `LLMResponse`s instead of
|
|
98
|
+
a real provider.
|
|
99
|
+
- **Injected fake SDK doubles** for anything exercising a specific
|
|
100
|
+
provider's request/response translation — `tests/test_llm_factory.py`
|
|
101
|
+
stands in a `SimpleNamespace` for `anthropic.Anthropic`/`openai.OpenAI`
|
|
102
|
+
via each client's existing `client=` constructor argument, so the test
|
|
103
|
+
verifies governed's own translation logic, not a vendor's wire format.
|
|
104
|
+
|
|
105
|
+
For anything that shells out to a subprocess or an external CLI (a code
|
|
106
|
+
execution backend, an HTTP sink), monkeypatch `subprocess.Popen`/`.run` or
|
|
107
|
+
the relevant transport rather than requiring the real binary or endpoint —
|
|
108
|
+
`tests/test_code_execution.py`'s `DockerCodeExecutionBackend` tests are the
|
|
109
|
+
template: real Docker is never required, but the command construction, the
|
|
110
|
+
timeout/kill path, and the "CLI not found" path are all exercised.
|
|
111
|
+
|
|
112
|
+
Registry mutations in tests go through `monkeypatch.setitem` on the
|
|
113
|
+
underlying private dict (e.g. `_TOOL_REGISTRY`, `_SKILL_SOURCE_REGISTRY`),
|
|
114
|
+
not the public `register_*()` function directly — this gets automatic
|
|
115
|
+
cleanup with no risk of one test's registration leaking into the next.
|
|
116
|
+
`tests/test_plugin_registries.py` is the reference.
|
|
117
|
+
|
|
118
|
+
## Style
|
|
119
|
+
|
|
120
|
+
`ruff` (lint + format) and `mypy --strict` are the enforced style — there's
|
|
121
|
+
no separate style guide beyond what those two catch. Beyond that, match the
|
|
122
|
+
codebase's existing voice: docstrings explain *why* a design choice was
|
|
123
|
+
made and what its limits are, not just what a function does; comments are
|
|
124
|
+
rare and reserved for non-obvious constraints. Read a few existing modules
|
|
125
|
+
(`security/guardrails.py` and `llm/factory.py` are good examples) before
|
|
126
|
+
writing a large amount of new code.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
By contributing, you agree your contribution is licensed under this
|
|
131
|
+
project's [Apache License 2.0](LICENSE), per §5 of that license.
|
governed-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the
|
|
44
|
+
purposes of this License, Derivative Works shall not include works
|
|
45
|
+
that remain separable from, or merely link (or bind by name) to the
|
|
46
|
+
interfaces of, the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on behalf of Yourself, assuming sole
|
|
171
|
+
responsibility, not on behalf of any other Contributor, and only
|
|
172
|
+
if You agree to indemnify, defend, and hold each Contributor
|
|
173
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
174
|
+
such Contributor by reason of your accepting any such warranty or
|
|
175
|
+
additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 governed contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|