provena 0.6.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.
- provena-0.6.0/.github/ISSUE_TEMPLATE/bug_report.yml +73 -0
- provena-0.6.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- provena-0.6.0/.github/ISSUE_TEMPLATE/feature_request.yml +46 -0
- provena-0.6.0/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- provena-0.6.0/.github/workflows/ci.yml +44 -0
- provena-0.6.0/.github/workflows/publish.yml +78 -0
- provena-0.6.0/.gitignore +45 -0
- provena-0.6.0/CHANGELOG.md +49 -0
- provena-0.6.0/CODE_OF_CONDUCT.md +62 -0
- provena-0.6.0/CONTRIBUTING.md +99 -0
- provena-0.6.0/LICENSE +161 -0
- provena-0.6.0/PKG-INFO +230 -0
- provena-0.6.0/README.md +184 -0
- provena-0.6.0/SECURITY.md +40 -0
- provena-0.6.0/examples/quickstart.py +21 -0
- provena-0.6.0/examples/rag_pipeline.py +55 -0
- provena-0.6.0/examples/tamper_detection.py +39 -0
- provena-0.6.0/pyproject.toml +115 -0
- provena-0.6.0/src/provena/__init__.py +26 -0
- provena-0.6.0/src/provena/__main__.py +3 -0
- provena-0.6.0/src/provena/cli/__init__.py +0 -0
- provena-0.6.0/src/provena/cli/main.py +315 -0
- provena-0.6.0/src/provena/exporters/__init__.py +5 -0
- provena-0.6.0/src/provena/exporters/otel.py +70 -0
- provena-0.6.0/src/provena/hasher.py +84 -0
- provena-0.6.0/src/provena/integrations/__init__.py +0 -0
- provena-0.6.0/src/provena/integrations/langchain.py +90 -0
- provena-0.6.0/src/provena/integrations/llamaindex.py +79 -0
- provena-0.6.0/src/provena/models.py +287 -0
- provena-0.6.0/src/provena/py.typed +0 -0
- provena-0.6.0/src/provena/storage.py +340 -0
- provena-0.6.0/src/provena/trail.py +619 -0
- provena-0.6.0/src/provena/validators/__init__.py +6 -0
- provena-0.6.0/src/provena/validators/freshness.py +257 -0
- provena-0.6.0/src/provena/validators/provenance.py +64 -0
- provena-0.6.0/tests/conftest.py +46 -0
- provena-0.6.0/tests/test_cli.py +376 -0
- provena-0.6.0/tests/test_freshness.py +326 -0
- provena-0.6.0/tests/test_hasher.py +121 -0
- provena-0.6.0/tests/test_integration_e2e.py +701 -0
- provena-0.6.0/tests/test_integrations.py +191 -0
- provena-0.6.0/tests/test_models.py +329 -0
- provena-0.6.0/tests/test_otel.py +245 -0
- provena-0.6.0/tests/test_provenance.py +113 -0
- provena-0.6.0/tests/test_storage.py +238 -0
- provena-0.6.0/tests/test_trail.py +523 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug in Provena
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for reporting a bug! Please fill in the details below.
|
|
9
|
+
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: description
|
|
12
|
+
attributes:
|
|
13
|
+
label: What happened?
|
|
14
|
+
description: A clear description of the bug.
|
|
15
|
+
placeholder: "When I call trail.log() with..."
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: reproduce
|
|
21
|
+
attributes:
|
|
22
|
+
label: Steps to reproduce
|
|
23
|
+
description: Minimal code or steps to reproduce the issue.
|
|
24
|
+
render: python
|
|
25
|
+
placeholder: |
|
|
26
|
+
from provena import ContextTrail
|
|
27
|
+
trail = ContextTrail(backend="memory")
|
|
28
|
+
# ...
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: expected
|
|
34
|
+
attributes:
|
|
35
|
+
label: Expected behavior
|
|
36
|
+
description: What you expected to happen.
|
|
37
|
+
validations:
|
|
38
|
+
required: true
|
|
39
|
+
|
|
40
|
+
- type: textarea
|
|
41
|
+
id: actual
|
|
42
|
+
attributes:
|
|
43
|
+
label: Actual behavior
|
|
44
|
+
description: What actually happened. Include error messages or tracebacks.
|
|
45
|
+
validations:
|
|
46
|
+
required: true
|
|
47
|
+
|
|
48
|
+
- type: input
|
|
49
|
+
id: version
|
|
50
|
+
attributes:
|
|
51
|
+
label: Provena version
|
|
52
|
+
placeholder: "0.5.0"
|
|
53
|
+
validations:
|
|
54
|
+
required: true
|
|
55
|
+
|
|
56
|
+
- type: input
|
|
57
|
+
id: python
|
|
58
|
+
attributes:
|
|
59
|
+
label: Python version
|
|
60
|
+
placeholder: "3.12"
|
|
61
|
+
validations:
|
|
62
|
+
required: true
|
|
63
|
+
|
|
64
|
+
- type: dropdown
|
|
65
|
+
id: backend
|
|
66
|
+
attributes:
|
|
67
|
+
label: Storage backend
|
|
68
|
+
options:
|
|
69
|
+
- SQLite (default)
|
|
70
|
+
- InMemory
|
|
71
|
+
- Not applicable
|
|
72
|
+
validations:
|
|
73
|
+
required: true
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: true
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Documentation
|
|
4
|
+
url: https://github.com/rajfirke/provena#readme
|
|
5
|
+
about: Read the README for usage guides and API reference.
|
|
6
|
+
- name: Security Vulnerability
|
|
7
|
+
url: https://github.com/rajfirke/provena/security/advisories/new
|
|
8
|
+
about: Report security vulnerabilities privately (do NOT open a public issue).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or improvement
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Have an idea for Provena? We'd love to hear it.
|
|
9
|
+
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: problem
|
|
12
|
+
attributes:
|
|
13
|
+
label: Problem or motivation
|
|
14
|
+
description: What problem does this feature solve? Why do you need it?
|
|
15
|
+
placeholder: "I'm trying to govern context from [framework] but there's no adapter..."
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: solution
|
|
21
|
+
attributes:
|
|
22
|
+
label: Proposed solution
|
|
23
|
+
description: How do you think this should work? Code examples welcome.
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: alternatives
|
|
29
|
+
attributes:
|
|
30
|
+
label: Alternatives considered
|
|
31
|
+
description: What workarounds or alternatives have you tried?
|
|
32
|
+
|
|
33
|
+
- type: dropdown
|
|
34
|
+
id: area
|
|
35
|
+
attributes:
|
|
36
|
+
label: Area
|
|
37
|
+
options:
|
|
38
|
+
- Core (trail, storage, models)
|
|
39
|
+
- Validator (provenance, freshness)
|
|
40
|
+
- Integration (LangChain, LlamaIndex, other framework)
|
|
41
|
+
- Exporter (OpenTelemetry, other)
|
|
42
|
+
- CLI
|
|
43
|
+
- Documentation
|
|
44
|
+
- Other
|
|
45
|
+
validations:
|
|
46
|
+
required: true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## What does this PR do?
|
|
2
|
+
|
|
3
|
+
<!-- A clear description of what this PR changes and why. -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] Tests added/updated for the change
|
|
8
|
+
- [ ] `ruff check src/ tests/` passes
|
|
9
|
+
- [ ] `ruff format --check src/ tests/` passes
|
|
10
|
+
- [ ] `mypy src/provena/` passes
|
|
11
|
+
- [ ] `pytest` passes with no failures
|
|
12
|
+
- [ ] CHANGELOG.md updated (if user-facing change)
|
|
13
|
+
|
|
14
|
+
## Related Issues
|
|
15
|
+
|
|
16
|
+
<!-- Link any related issues: Fixes #123, Relates to #456 -->
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
permissions: {}
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install -e ".[dev,cli,otel]"
|
|
30
|
+
pip install opentelemetry-sdk
|
|
31
|
+
- name: Lint
|
|
32
|
+
run: ruff check src/ tests/
|
|
33
|
+
- name: Format check
|
|
34
|
+
run: ruff format --check src/ tests/
|
|
35
|
+
- name: Type check
|
|
36
|
+
run: mypy src/provena/
|
|
37
|
+
- name: Test
|
|
38
|
+
run: pytest --cov=provena --cov-report=xml -v
|
|
39
|
+
- name: Upload coverage
|
|
40
|
+
if: matrix.python-version == '3.12'
|
|
41
|
+
uses: actions/upload-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: coverage
|
|
44
|
+
path: coverage.xml
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
name: Build distribution
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- name: Install build tools
|
|
20
|
+
run: python -m pip install --upgrade pip build
|
|
21
|
+
- name: Build sdist and wheel
|
|
22
|
+
run: python -m build
|
|
23
|
+
- name: Check distribution
|
|
24
|
+
run: |
|
|
25
|
+
pip install twine
|
|
26
|
+
twine check dist/*
|
|
27
|
+
- name: Upload distribution artifacts
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish-testpypi:
|
|
34
|
+
name: Publish to TestPyPI
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment: testpypi
|
|
38
|
+
permissions:
|
|
39
|
+
id-token: write
|
|
40
|
+
steps:
|
|
41
|
+
- name: Download distribution artifacts
|
|
42
|
+
uses: actions/download-artifact@v4
|
|
43
|
+
with:
|
|
44
|
+
name: dist
|
|
45
|
+
path: dist/
|
|
46
|
+
- name: Publish to TestPyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
with:
|
|
49
|
+
repository-url: https://test.pypi.org/legacy/
|
|
50
|
+
|
|
51
|
+
publish-pypi:
|
|
52
|
+
name: Publish to PyPI
|
|
53
|
+
needs: [build, publish-testpypi]
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
environment: pypi
|
|
56
|
+
permissions:
|
|
57
|
+
id-token: write
|
|
58
|
+
steps:
|
|
59
|
+
- name: Download distribution artifacts
|
|
60
|
+
uses: actions/download-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
name: dist
|
|
63
|
+
path: dist/
|
|
64
|
+
- name: Publish to PyPI
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
66
|
+
|
|
67
|
+
github-release:
|
|
68
|
+
name: Create GitHub Release
|
|
69
|
+
needs: publish-pypi
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
permissions:
|
|
72
|
+
contents: write
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v4
|
|
75
|
+
- name: Create GitHub Release
|
|
76
|
+
env:
|
|
77
|
+
GH_TOKEN: ${{ github.token }}
|
|
78
|
+
run: gh release create "${{ github.ref_name }}" --generate-notes
|
provena-0.6.0/.gitignore
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Planning & research docs (not part of the codebase)
|
|
2
|
+
project-context/
|
|
3
|
+
blogs/
|
|
4
|
+
roadmap/
|
|
5
|
+
plan/
|
|
6
|
+
IMPLEMENTATION-BLUEPRINT.md
|
|
7
|
+
info.md
|
|
8
|
+
|
|
9
|
+
# Python
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
*.so
|
|
14
|
+
*.egg-info/
|
|
15
|
+
*.egg
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
.eggs/
|
|
19
|
+
|
|
20
|
+
# Virtual environments
|
|
21
|
+
.venv/
|
|
22
|
+
venv/
|
|
23
|
+
env/
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.idea/
|
|
27
|
+
.vscode/
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
*~
|
|
31
|
+
|
|
32
|
+
# Testing
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
.coverage
|
|
35
|
+
htmlcov/
|
|
36
|
+
.mypy_cache/
|
|
37
|
+
.ruff_cache/
|
|
38
|
+
|
|
39
|
+
# Provena runtime
|
|
40
|
+
*.db
|
|
41
|
+
provena.db
|
|
42
|
+
|
|
43
|
+
# OS
|
|
44
|
+
.DS_Store
|
|
45
|
+
Thumbs.db
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to Provena are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.6.0] - 2026-07-17
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Google-style docstrings on all public API classes and methods
|
|
13
|
+
- PyPI trusted publishing via GitHub Actions with OIDC authentication
|
|
14
|
+
- PyPI version and download badges in README
|
|
15
|
+
- `ContextTrail.query()` filters for exact provenance and freshness status values
|
|
16
|
+
|
|
17
|
+
## [0.5.0] - 2026-07-15
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- **Framework integrations**: LangChain `ProvenaCallback` and LlamaIndex `ProvenaPostprocessor`
|
|
21
|
+
- **OpenTelemetry export**: Span emission for every governance event (`provena[otel]`)
|
|
22
|
+
- **CLI tools**: `provena audit`, `provena verify`, `provena report`, `provena summary`
|
|
23
|
+
- **FreshnessChecker**: Regex-based temporal detection (ISO dates, month-year, quarters, contextual years)
|
|
24
|
+
- **HMAC-SHA256 signing**: Optional compliance mode with external signing key
|
|
25
|
+
- **Config validation**: `max_age_days` and `max_content_bytes` validated on construction
|
|
26
|
+
- **InMemoryBackend**: For testing without filesystem side effects
|
|
27
|
+
- **SQLite schema versioning**: `user_version` pragma with automatic migration
|
|
28
|
+
- **`trail.annotate()`**: Human oversight annotations (EU AI Act Art. 14)
|
|
29
|
+
- **`trail.explain()`/`summary()`**: Governance transparency (EU AI Act Art. 13)
|
|
30
|
+
- **Error resilience**: Governance failures never crash user code
|
|
31
|
+
- **Content type dispatch**: Automatic handling of str, bytes, list, dict, LangChain Documents
|
|
32
|
+
- **226 tests** with 89% coverage across all components
|
|
33
|
+
|
|
34
|
+
### Architecture
|
|
35
|
+
- Pure Python, zero stdlib-only dependencies for core
|
|
36
|
+
- SHA-256 hash-chained Merkle audit trail
|
|
37
|
+
- Frozen dataclasses with slots for all models
|
|
38
|
+
- Per-instance threading locks for thread safety
|
|
39
|
+
- Append-only SQLite with WAL mode
|
|
40
|
+
|
|
41
|
+
## [0.1.0] - 2026-07-13
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- Initial implementation: `ContextTrail`, `@trail.track` decorator
|
|
45
|
+
- Core models: `ContextEntry`, `TrailRecord`, `ProvenanceMetadata`, `ValidationResult`
|
|
46
|
+
- `ProvenanceValidator` with configurable required fields
|
|
47
|
+
- `HashChain` with SHA-256
|
|
48
|
+
- `SQLiteBackend` with append-only storage
|
|
49
|
+
- `ContextSource` enum: retriever, tool, agent, memory, mcp, custom
|
|
@@ -0,0 +1,62 @@
|
|
|
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 status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity 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 for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
49
|
+
an individual is officially representing the community in public spaces.
|
|
50
|
+
|
|
51
|
+
## Enforcement
|
|
52
|
+
|
|
53
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
54
|
+
reported to the project maintainer at **rajfirke on GitHub**.
|
|
55
|
+
|
|
56
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
57
|
+
|
|
58
|
+
## Attribution
|
|
59
|
+
|
|
60
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
|
|
61
|
+
version 2.1, available at
|
|
62
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Contributing to Provena
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to Provena! This document covers everything you need to get started.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone and install
|
|
9
|
+
git clone https://github.com/rajfirke/provena.git
|
|
10
|
+
cd provena
|
|
11
|
+
python -m venv .venv
|
|
12
|
+
source .venv/bin/activate
|
|
13
|
+
pip install -e ".[dev,cli,otel]"
|
|
14
|
+
pip install opentelemetry-sdk # for OTel tests
|
|
15
|
+
|
|
16
|
+
# Verify everything works
|
|
17
|
+
pytest
|
|
18
|
+
ruff check src/ tests/
|
|
19
|
+
mypy src/provena/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
src/provena/
|
|
26
|
+
├── __init__.py # Public API
|
|
27
|
+
├── models.py # Core data types (ContextEntry, TrailRecord, etc.)
|
|
28
|
+
├── hasher.py # SHA-256 / HMAC-SHA256 hash chain
|
|
29
|
+
├── storage.py # SQLite + InMemory backends
|
|
30
|
+
├── trail.py # ContextTrail engine + @track decorator
|
|
31
|
+
├── validators/
|
|
32
|
+
│ ├── provenance.py # Provenance validation (VALID/MISSING/INCOMPLETE)
|
|
33
|
+
│ └── freshness.py # Freshness checking with regex temporal detection
|
|
34
|
+
├── exporters/
|
|
35
|
+
│ └── otel.py # OpenTelemetry span export
|
|
36
|
+
├── integrations/
|
|
37
|
+
│ ├── langchain.py # LangChain BaseCallbackHandler
|
|
38
|
+
│ └── llamaindex.py # LlamaIndex BaseNodePostprocessor
|
|
39
|
+
└── cli/
|
|
40
|
+
└── main.py # Click-based CLI (audit/verify/report/summary)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## How to Contribute
|
|
44
|
+
|
|
45
|
+
### Adding a New Validator
|
|
46
|
+
|
|
47
|
+
1. Create `src/provena/validators/your_validator.py`
|
|
48
|
+
2. Follow the pattern in `provenance.py` — accept a `ContextEntry`, return a result dataclass
|
|
49
|
+
3. Add tests in `tests/test_your_validator.py`
|
|
50
|
+
4. Integrate into `trail.py` `_log_internal()` if it should run on every log call
|
|
51
|
+
|
|
52
|
+
### Adding a New Integration
|
|
53
|
+
|
|
54
|
+
1. Create `src/provena/integrations/your_framework.py`
|
|
55
|
+
2. Use try/except for the framework import (see `langchain.py` for the pattern)
|
|
56
|
+
3. Add the framework as an optional dependency in `pyproject.toml`
|
|
57
|
+
4. Add tests using mock objects (see `test_integrations.py`)
|
|
58
|
+
|
|
59
|
+
### Adding a New Storage Backend
|
|
60
|
+
|
|
61
|
+
1. Implement the `StorageBackend` protocol from `storage.py`
|
|
62
|
+
2. Required methods: `append`, `get`, `get_last`, `count`, `all_records`, `query`, `add_annotation`, `close`
|
|
63
|
+
3. Add tests that verify parity with `InMemoryBackend`
|
|
64
|
+
|
|
65
|
+
## Code Standards
|
|
66
|
+
|
|
67
|
+
- **Formatter**: `ruff format`
|
|
68
|
+
- **Linter**: `ruff check` (rules: E, F, I, N, UP, W, B, SIM, RUF)
|
|
69
|
+
- **Type checker**: `mypy --strict`
|
|
70
|
+
- **Tests**: `pytest` with `pytest-cov` — aim for 90%+ coverage
|
|
71
|
+
- **Python**: 3.10+ (use `from __future__ import annotations`)
|
|
72
|
+
|
|
73
|
+
All checks must pass before merging. CI runs automatically on every PR.
|
|
74
|
+
|
|
75
|
+
## Pull Request Process
|
|
76
|
+
|
|
77
|
+
1. Fork the repo and create a branch from `main`
|
|
78
|
+
2. Make your changes with tests
|
|
79
|
+
3. Run the full check suite:
|
|
80
|
+
```bash
|
|
81
|
+
ruff check src/ tests/
|
|
82
|
+
ruff format --check src/ tests/
|
|
83
|
+
mypy src/provena/
|
|
84
|
+
pytest --cov=provena
|
|
85
|
+
```
|
|
86
|
+
4. Open a PR with a clear description of what and why
|
|
87
|
+
5. Respond to review feedback
|
|
88
|
+
|
|
89
|
+
## Reporting Bugs
|
|
90
|
+
|
|
91
|
+
Use the [bug report template](https://github.com/rajfirke/provena/issues/new?template=bug_report.yml) on GitHub Issues.
|
|
92
|
+
|
|
93
|
+
## Requesting Features
|
|
94
|
+
|
|
95
|
+
Use the [feature request template](https://github.com/rajfirke/provena/issues/new?template=feature_request.yml) on GitHub Issues.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
|
provena-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
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 not
|
|
32
|
+
limited to compiled object code, generated documentation, and
|
|
33
|
+
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
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
48
|
+
version of the Work and any modifications or additions to that Work or
|
|
49
|
+
Derivative Works thereof, that is intentionally submitted to the Licensor
|
|
50
|
+
for inclusion in the Work by the copyright owner or by an individual or
|
|
51
|
+
Legal Entity authorized to submit on behalf of the copyright owner. For
|
|
52
|
+
the purposes of this definition, "submitted" means any form of electronic,
|
|
53
|
+
verbal, or written communication sent to the Licensor or its representatives,
|
|
54
|
+
including but not limited to communication on electronic mailing lists,
|
|
55
|
+
source code control systems, and issue tracking systems that are managed by,
|
|
56
|
+
or on behalf of, the Licensor for the purpose of discussing and improving the
|
|
57
|
+
Work, but excluding communication that is conspicuously marked or otherwise
|
|
58
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
59
|
+
|
|
60
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
61
|
+
of whom a Contribution has been received by the Licensor and subsequently
|
|
62
|
+
incorporated within the Work.
|
|
63
|
+
|
|
64
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
65
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
66
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
67
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
68
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
69
|
+
Object form.
|
|
70
|
+
|
|
71
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
72
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
73
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
|
|
74
|
+
this section) patent license to make, have made, use, offer to sell, sell,
|
|
75
|
+
import, and otherwise transfer the Work, where such license applies only
|
|
76
|
+
to those patent claims licensable by such Contributor that are necessarily
|
|
77
|
+
infringed by their Contribution(s) alone or by combination of their
|
|
78
|
+
Contribution(s) with the Work to which such Contribution(s) was submitted.
|
|
79
|
+
|
|
80
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
81
|
+
Derivative Works thereof in any medium, with or without modifications, and
|
|
82
|
+
in Source or Object form, provided that You meet the following conditions:
|
|
83
|
+
|
|
84
|
+
(a) You must give any other recipients of the Work or Derivative Works a
|
|
85
|
+
copy of this License; and
|
|
86
|
+
|
|
87
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
88
|
+
that You changed the files; and
|
|
89
|
+
|
|
90
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
91
|
+
distribute, all copyright, patent, trademark, and attribution notices
|
|
92
|
+
from the Source form of the Work, excluding those notices that do not
|
|
93
|
+
pertain to any part of the Derivative Works; and
|
|
94
|
+
|
|
95
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
96
|
+
then any Derivative Works that You distribute must include a readable
|
|
97
|
+
copy of the attribution notices contained within such NOTICE file,
|
|
98
|
+
excluding any notices that do not pertain to any part of the Derivative
|
|
99
|
+
Works, in at least one of the following places: within a NOTICE text
|
|
100
|
+
file distributed as part of the Derivative Works; within the Source form
|
|
101
|
+
or documentation, if provided along with the Derivative Works; or,
|
|
102
|
+
within a display generated by the Derivative Works, if and wherever such
|
|
103
|
+
third-party notices normally appear. The contents of the NOTICE file are
|
|
104
|
+
for informational purposes only and do not modify the License. You may
|
|
105
|
+
add Your own attribution notices within Derivative Works that You
|
|
106
|
+
distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
107
|
+
provided that such additional attribution notices cannot be construed as
|
|
108
|
+
modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own copyright statement to Your modifications and may
|
|
111
|
+
provide additional or different license terms and conditions for use,
|
|
112
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
113
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
114
|
+
distribution of the Work otherwise complies with the conditions stated
|
|
115
|
+
in this License.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
118
|
+
Contribution intentionally submitted for inclusion in the Work by You to
|
|
119
|
+
the Licensor shall be under the terms and conditions of this License,
|
|
120
|
+
without any additional terms or conditions.
|
|
121
|
+
|
|
122
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
123
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
124
|
+
required for reasonable and customary use in describing the origin of the
|
|
125
|
+
Work and reproducing the content of the NOTICE file.
|
|
126
|
+
|
|
127
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
128
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
129
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
130
|
+
ANY KIND, either express or implied, including, without limitation, any
|
|
131
|
+
warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
|
|
132
|
+
FITNESS FOR A PARTICULAR PURPOSE.
|
|
133
|
+
|
|
134
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
135
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
136
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
|
137
|
+
in writing, shall any Contributor be liable to You for damages, including
|
|
138
|
+
any direct, indirect, special, incidental, or consequential damages of any
|
|
139
|
+
character arising as a result of this License or out of the use or inability
|
|
140
|
+
to use the Work.
|
|
141
|
+
|
|
142
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
143
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
144
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
145
|
+
and/or rights consistent with this License.
|
|
146
|
+
|
|
147
|
+
END OF TERMS AND CONDITIONS
|
|
148
|
+
|
|
149
|
+
Copyright 2026 Raj Firke
|
|
150
|
+
|
|
151
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
152
|
+
you may not use this file except in compliance with the License.
|
|
153
|
+
You may obtain a copy of the License at
|
|
154
|
+
|
|
155
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
156
|
+
|
|
157
|
+
Unless required by applicable law or agreed to in writing, software
|
|
158
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
160
|
+
See the License for the specific language governing permissions and
|
|
161
|
+
limitations under the License.
|