[RAG API] Define generic contracts and ports - #5
Merged
Conversation
Define the provider-neutral 0.1.0 values, errors, synchronous ports, and caller-owned borrowing boundary. Add locked tooling, pinned CI, contract and artifact verification, public documentation, and the four-module index. Refs #2
Configure the uv project environment from step-level runner variables so GitHub can validate and start the matrix jobs. Refs #2
There was a problem hiding this comment.
Pull request overview
Introduces the initial generic-rag Python distribution as a provider-neutral “contracts-only” foundation: immutable validated value objects, typed public error categories, and synchronous collaborator protocols with explicit caller-owned borrowing. The change also establishes packaging, verification, and boundary/architecture enforcement so downstream projection (#3) and retrieval (#4) work can depend on stable public contracts.
Changes:
- Add
generic_ragpublic modules (errors,contracts,ports) plus an intentionally empty package root, with strict runtime validation and closed string enums. - Add comprehensive contract/boundary test suite including clean-import and artifact verification probes.
- Add packaging (
pyproject.toml,py.typed), CI workflow, and supporting documentation/policies including the Python module index.
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_retrieval_contracts.py | Contract tests for retrieval values (query/hit/result/outcomes) and invariants (bounded, score-free, rank/dedup rules). |
| tests/test_projection_contracts.py | Contract tests for projection identity/checkpoint/receipt and outcome/count/checkpoint invariants. |
| tests/test_ports.py | Contract tests for runtime-checkable protocols and the Borrowed lifecycle/no-op semantics, plus deterministic witnesses. |
| tests/test_package_boundaries.py | Boundary tests: exact module inventory/exports, internal dependency graph, forbidden imports/operations, clean isolated imports, module-index parity. |
| tests/test_errors.py | Tests for public exception exports and hierarchy invariants. |
| tests/test_contract_values.py | Contract tests for core immutable value objects (documents/fragments/embeddings) and runtime type exactness. |
| tests/support/verify_artifacts.py | Wheel/sdist structural verification (no deps, no shipped tests, expected file set, safe archive member rules, metadata checks). |
| tests/support/clean_import_probe.py | Isolated import probe with audit-hook and patched APIs to forbid I/O, process, network, or thread actions at import time. |
| src/generic_rag/py.typed | Declares the package as typed (PEP 561 marker). |
| src/generic_rag/ports.py | Defines collaborator Protocols (Embedder, index reader/writer, lexical retriever) and Borrowed[T] context manager contract. |
| src/generic_rag/errors.py | Defines public error categories and exported surface (__all__). |
| src/generic_rag/contracts.py | Implements frozen/slotted validated contract dataclasses and closed StrEnum outcomes for projection and retrieval. |
| src/generic_rag/init.py | Establishes an import-only root with no re-exports (__all__ = ()). |
| README.md | Project overview, usage example, boundary statements, planned issues linkage, and local verification commands. |
| PYTHON_MODULE_INDEX.md | Module inventory/index documenting responsibilities, exports, dependencies, side effects, and verification references. |
| pyproject.toml | Packaging metadata, empty runtime dependencies, setuptools config, Ruff/Mypy configuration, and dependency groups. |
| GITHUB_WORKFLOW.md | GitHub workflow policy defining planning gate, metadata, branching/PR rules, and traceability requirements. |
| docs/security-and-privacy.md | Documents security/privacy boundary and caller responsibilities for sensitive data and provider effects. |
| docs/lifecycle.md | Documents explicit caller-owned lifecycle model and Borrowed[T] semantics. |
| docs/api.md | Public API reference: exports, invariants, value rules, outcomes, ports, and non-goals for 0.1.0. |
| DEPENDENCY_POLICY.md | Dependency governance for Python packaging and lockfile discipline. |
| COMMIT_POLICY.md | Commit structure and hygiene rules for coherent reviewable history. |
| AGENTS.md | Repository engineering workflow and gates used by contributors/agents. |
| AGENT_TASK_RUNBOOK.md | Operational runbook for planning gate, branch/worktree model, and traceability verification steps. |
| .github/workflows/ci.yml | CI matrix with pinned actions, uv-based locked env setup, tests, lint/format/type/compile checks, and artifact/import verification. |
| .codex/repository-engineering-kit.lock.json | Locks repository-engineering kit installation/profiles and managed file provenance. |
| .codex/agents/test_engineer.toml | Defines test specialist role and expectations. |
| .codex/agents/runtime_implementer.toml | Defines runtime implementation specialist role and constraints. |
| .codex/agents/requirements_analyst.toml | Defines read-only requirements analyst role and modularity gate classification responsibilities. |
| .codex/agents/regression_diagnostician.toml | Defines read-only regression diagnostician role and boundary impact reporting. |
| .codex/agents/modularity_maintainer/PYTHON_MODULARITY_POLICY.md | Python modularity policy governing boundaries, index requirements, and compatibility rules. |
| .codex/agents/modularity_maintainer.toml | Defines modularity maintainer role, modes, and index/policy workflow. |
| .codex/agents/documentation_maintainer.toml | Defines documentation maintainer role and constraints. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generic-rag0.1.0 package with immutable provider-neutral values, typed failures, synchronous collaborator protocols, and caller-ownedBorrowedresourcesBoundary
This child establishes contracts only. Projection/chunking remains in #3 and retrieval/fusion/composition remains in #4. Public imports come from
generic_rag.errors,generic_rag.contracts, andgeneric_rag.ports; the root has no re-exports.Verification
py.typedverification: passedDependency policy
[project].dependenciesis emptyRefs #2