Skip to content

Commit 8a72048

Browse files
feat: qp-vault v0.5.0 — governed knowledge store
Standalone Python package for governed knowledge storage. Content-addressed (SHA3-256), trust-tiered, lifecycle-managed, Merkle-verified, air-gap native. 24 source modules, 375 tests, 100/100 security score. 11 documentation guides, full CLI, FastAPI integration, plugin system.
0 parents  commit 8a72048

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+11501
-0
lines changed

.github/workflows/python-ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- run: pip install ruff
21+
- run: ruff check src/ tests/
22+
23+
typecheck:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
- run: pip install -e ".[sqlite,fastapi,integrity,cli,dev]"
31+
- run: mypy src/qp_vault/
32+
33+
test:
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
python-version: ["3.12", "3.13", "3.14"]
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
allow-prereleases: true
44+
- run: pip install -e ".[sqlite,fastapi,integrity,cli,dev]"
45+
- run: pytest tests/ -v --tb=short --cov=qp_vault --cov-report=term-missing

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
dist/
6+
build/
7+
8+
# Virtual environments
9+
.venv/
10+
venv/
11+
12+
# Testing
13+
.pytest_cache/
14+
.coverage
15+
htmlcov/
16+
17+
# Linting & Type Checking
18+
.ruff_cache/
19+
.mypy_cache/
20+
21+
# IDE
22+
.idea/
23+
.vscode/
24+
*.swp
25+
*.swo
26+
27+
# OS
28+
.DS_Store
29+
Thumbs.db
30+
31+
# Database
32+
*.db
33+
*.sqlite
34+
35+
# Audit logs (generated at runtime)
36+
audit.jsonl

CHANGELOG.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.5.0] - 2026-04-06
11+
12+
### Added
13+
- Plugin system with `@embedder`, `@parser`, `@policy` decorators
14+
- Air-gap plugin loading via `--plugins-dir` (drop .py files)
15+
- Entry point discovery for installed plugin packages
16+
- FastAPI routes via `create_vault_router()` (`[fastapi]` extra)
17+
- All REST endpoints: resources CRUD, search, verify, health, lifecycle, proof
18+
19+
## [0.4.0] - 2026-04-06
20+
21+
### Added
22+
- Memory layers: OPERATIONAL, STRATEGIC, COMPLIANCE with per-layer defaults
23+
- `vault.layer(MemoryLayer.OPERATIONAL)` returns scoped LayerView
24+
- COMPLIANCE layer audits every read operation
25+
- Integrity detection: staleness scoring, duplicate detection, orphan detection
26+
- `vault.health()` composite score (0-100): coherence, freshness, uniqueness, connectivity
27+
- `vault.status()` includes `layer_details` breakdown
28+
29+
## [0.3.0] - 2026-04-06
30+
31+
### Added
32+
- Knowledge lifecycle state machine: DRAFT, REVIEW, ACTIVE, SUPERSEDED, EXPIRED, ARCHIVED
33+
- `vault.transition()`, `vault.supersede()`, `vault.chain()`, `vault.expiring()`
34+
- Temporal validity: `valid_from`, `valid_until` on resources
35+
- `vault.export_proof()` for Merkle proof export (auditor-verifiable)
36+
- Supersession chain cycle protection (max_length=1000)
37+
38+
## [0.2.0] - 2026-04-06
39+
40+
### Added
41+
- `vault` CLI tool: init, add, search, inspect, status, verify
42+
- Capsule audit integration (`[capsule]` extra)
43+
- PostgreSQL + pgvector + pg_trgm storage backend (`[postgres]` extra)
44+
- WebVTT and SRT transcript parsers with speaker attribution
45+
- `Vault.from_postgres()` and `Vault.from_config()` factory methods
46+
47+
### Security
48+
- FTS5 query sanitization (prevents injection via special characters)
49+
- Parameterized SQL queries in PostgreSQL backend (no string interpolation)
50+
51+
## [0.1.0] - 2026-04-05
52+
53+
### Added
54+
- Initial release
55+
- `Vault` (sync) and `AsyncVault` (async) main classes
56+
- 8 Pydantic domain models: Resource, Chunk, Collection, SearchResult, VaultEvent, VerificationResult, VaultVerificationResult, MerkleProof, HealthScore
57+
- 10 enumerations: TrustTier, DataClassification, ResourceType, ResourceStatus, Lifecycle, MemoryLayer, EventType
58+
- 5 Protocol interfaces: StorageBackend, EmbeddingProvider, AuditProvider, ParserProvider, PolicyProvider
59+
- SQLite storage backend with FTS5 full-text search (zero-config default)
60+
- Trust-weighted hybrid search: `relevance = (0.7 * vector + 0.3 * text) * trust_weight * freshness`
61+
- SHA3-256 content-addressed storage (CID per chunk, Merkle root per resource)
62+
- Semantic text chunker (token-aware, overlap, section detection)
63+
- Built-in text parser (30+ file extensions, zero deps)
64+
- JSON lines audit fallback (LogAuditor)
65+
- VaultConfig with TOML loading
66+
67+
### Security
68+
- Input validation: enum values, resource names, tags, metadata
69+
- Path traversal protection (name sanitization, null byte stripping)
70+
- Max file size enforcement (configurable)
71+
- Content null byte stripping on ingest
72+
73+
[unreleased]: https://github.com/quantumpipes/vault/compare/v0.5.0...HEAD
74+
[0.5.0]: https://github.com/quantumpipes/vault/compare/v0.4.0...v0.5.0
75+
[0.4.0]: https://github.com/quantumpipes/vault/compare/v0.3.0...v0.4.0
76+
[0.3.0]: https://github.com/quantumpipes/vault/compare/v0.2.0...v0.3.0
77+
[0.2.0]: https://github.com/quantumpipes/vault/compare/v0.1.0...v0.2.0
78+
[0.1.0]: https://github.com/quantumpipes/vault/releases/tag/v0.1.0

CODE_OF_CONDUCT.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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, religion, or sexual identity
10+
and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to a positive environment:
15+
16+
* Using welcoming and inclusive language
17+
* Being respectful of differing viewpoints and experiences
18+
* Gracefully accepting constructive criticism
19+
* Focusing on what is best for the community
20+
21+
Examples of unacceptable behavior:
22+
23+
* Trolling, insulting or derogatory comments, and personal or political attacks
24+
* Public or private harassment
25+
* Publishing others' private information without explicit permission
26+
* Other conduct which could reasonably be considered inappropriate
27+
28+
## Enforcement
29+
30+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
31+
reported to the project team at conduct@quantumpipes.io.
32+
33+
## Attribution
34+
35+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
36+
version 2.0.

CONTRIBUTING.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Contributing to qp-vault
2+
3+
Thank you for your interest in contributing to qp-vault. This document explains how to get involved.
4+
5+
## Repository Structure
6+
7+
```
8+
vault/
9+
├── src/qp_vault/ <- Source code
10+
│ ├── core/ <- Business logic (chunker, search, lifecycle)
11+
│ ├── storage/ <- Storage backends (SQLite, PostgreSQL)
12+
│ ├── processing/ <- File parsers (text, transcripts)
13+
│ ├── audit/ <- Audit providers (log, capsule)
14+
│ ├── integrity/ <- Health detection (staleness, duplicates)
15+
│ ├── plugins/ <- Plugin system (registry, decorators)
16+
│ ├── integrations/ <- Framework adapters (FastAPI)
17+
│ └── cli/ <- Command-line interface
18+
├── tests/ <- Test suite (375+ tests)
19+
├── docs/ <- Documentation
20+
└── examples/ <- Usage examples
21+
```
22+
23+
## Getting Started
24+
25+
```bash
26+
git clone https://github.com/quantumpipes/vault.git
27+
cd vault
28+
pip install -e ".[sqlite,cli,fastapi,integrity,dev]"
29+
make test
30+
```
31+
32+
## Types of Contributions
33+
34+
### Bug Fixes
35+
36+
- Open an issue describing the bug
37+
- Include a minimal reproduction case
38+
- Submit a PR with a test that fails before the fix and passes after
39+
40+
### New Storage Backends
41+
42+
Implement the `StorageBackend` Protocol in `src/qp_vault/protocols.py`:
43+
44+
```python
45+
class StorageBackend(Protocol):
46+
async def initialize(self) -> None: ...
47+
async def store_resource(self, resource: Resource) -> str: ...
48+
async def get_resource(self, resource_id: str) -> Resource | None: ...
49+
async def search(self, query: SearchQuery) -> list[SearchResult]: ...
50+
# ... see protocols.py for full interface
51+
```
52+
53+
### New Parsers
54+
55+
Use the `@parser` decorator:
56+
57+
```python
58+
from qp_vault.plugins import parser
59+
60+
@parser("my-format")
61+
class MyParser:
62+
supported_extensions = {".myf"}
63+
async def parse(self, path: Path) -> ParseResult:
64+
return ParseResult(text=extract(path))
65+
```
66+
67+
### New Embedding Providers
68+
69+
Use the `@embedder` decorator:
70+
71+
```python
72+
from qp_vault.plugins import embedder
73+
74+
@embedder("my-model")
75+
class MyEmbedder:
76+
dimensions = 768
77+
async def embed(self, texts: list[str]) -> list[list[float]]:
78+
return my_model.encode(texts)
79+
```
80+
81+
### Documentation
82+
83+
Improvements to README, API docs, examples, and tutorials.
84+
85+
## Code Standards
86+
87+
- **Type hints** on all function signatures
88+
- **Docstrings** on all public classes and methods
89+
- **Tests** for all new functionality (target 100% coverage)
90+
- **No hardcoded values**: use VaultConfig for all configurable settings
91+
- **Async-first**: all I/O operations must be async
92+
- **No deprecated crypto**: SHA3-256 only, no MD5/SHA1/RSA
93+
94+
## Running Tests
95+
96+
```bash
97+
make test # Run full test suite with coverage
98+
make lint # Run ruff linter
99+
make typecheck # Run mypy type checker
100+
make test-all # All of the above
101+
```
102+
103+
## Submitting Changes
104+
105+
1. Fork the repository
106+
2. Create a feature branch from `main`
107+
3. Write tests alongside your code
108+
4. Ensure `make test-all` passes
109+
5. Submit a pull request
110+
111+
## Security
112+
113+
If you discover a security vulnerability, please report it privately. See [SECURITY.md](SECURITY.md).
114+
115+
## License
116+
117+
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.

0 commit comments

Comments
 (0)