Skip to content

Commit 480d8cb

Browse files
authored
Merge pull request #114 from CoReason-AI/develop
## Summary This PR modernizes the `python_template` to align perfectly with the 2026+ CoReason "Shared Kernel" ecosystem. It completes the migration to the Zensical documentation engine, establishes a cutting-edge execution environment, and injects strict, machine-readable architectural directives into `AGENTS.md` to ensure all downstream generated projects are secure, deterministic, and natively understood by swarm LLMs. ## Key Changes * **Execution & Tooling:** * Enforced **Python 3.14** (including Free-Threading `3.14t`) as the strict runtime baseline. * Standardized on **`uv`** as the exclusive, lightning-fast dependency and project manager. * **Documentation Engine Migration:** * Eradicated `mkdocs` and legacy plugins, fully replacing them with `zensical` and `mkdocstrings-python`. * Replaced `mkdocs.yml` with the new, Jinja-templated `zensical.toml` configuration. * **AI-Native Constraints (`AGENTS.md`):** * **IP Defense:** Injected the Prosperity 3.0 `<legal_directive>` (Rules 5 & 6) to actively prevent downstream AI agents from unauthorized extraction or laundering of CoReason IP. * **Lexical Architecture:** Enforced the Anti-CRUD mandate and Categorical Suffixing (e.g., `...Intent`, `...Event`) to maintain pristine vector space embeddings. * **Mathematical Testing:** Mandated the use of the `hypothesis` library for property-based edge-case testing on Pydantic schemas. ## Impact Any new repository generated from this template will now be born as a 100% CoReason-compliant node, featuring state-of-the-art Python 3.14+ execution, ultra-fast `uv` resolution, and ironclad prompt-level security against architectural drift.
2 parents 6a2c578 + c01d410 commit 480d8cb

28 files changed

Lines changed: 509 additions & 316 deletions

AUDIT.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ This document outlines the results of an audit of the repository against modern
77
### 1. Central Configuration and Legacy Files
88
- **`pyproject.toml`**: **[PASS]** A `pyproject.toml` file exists at the root, which is mandatory for modern packaging.
99
- **Legacy Files**: **[PASS]** `setup.py`, `setup.cfg`, and `requirements.txt` are not used for core metadata or dependency management. All configuration is correctly centralized in `pyproject.toml`.
10-
- **`poetry.lock`**: **[FAIL]** A `poetry.lock` file is present. This is a legacy artifact from a previous Poetry-based setup and is inconsistent with the current `setuptools` build backend. It must be removed.
10+
- **`poetry.lock`**: **[PASS]** The legacy `poetry.lock` file has been successfully removed.
1111
- **`MANIFEST.in`**: **[PASS]** This file is not present.
1212

1313
### 2. Build System (PEP 517 & PEP 518)
1414
- **`[build-system]` Table**: **[PASS]** This table is present in `pyproject.toml`.
15-
- **`build-backend`**: **[PASS]** A modern, PEP 517-compliant backend, `setuptools.build_meta`, is specified.
16-
- **`requires`**: **[PASS]** The build dependencies are correctly listed as `["setuptools>=61.0"]`.
15+
- **`build-backend`**: **[PASS]** A modern, PEP 517-compliant backend, `hatchling.build`, is specified.
16+
- **`requires`**: **[PASS]** The build dependencies are correctly listed as `["hatchling"]`.
1717

1818
### 3. Project Metadata (PEP 621)
1919
- **`[project]` Table**: **[PASS]** This table is present in `pyproject.toml`.
@@ -25,7 +25,7 @@ This document outlines the results of an audit of the repository against modern
2525

2626
### 4. Dependencies (PEP 508)
2727
- **`dependencies`**: **[PASS]** Runtime dependencies are correctly specified as an empty array.
28-
- **`optional-dependencies`**: **[PASS]** Extras for development are correctly defined in `[project.optional-dependencies]`.
28+
- **`optional-dependencies`**: **[PASS]** Extras for development are correctly defined using PEP 735 `[dependency-groups]`.
2929

3030
### 5. Project Structure and Layout
3131
- **Layout**: **[PASS]** The project uses the recommended `src` layout (`src/my_python_project/`).
@@ -37,11 +37,11 @@ This document outlines the results of an audit of the repository against modern
3737
- **Configuration**: **[PASS]** The testing configuration is centralized in `[tool.pytest.ini_options]` within `pyproject.toml`.
3838

3939
## Conclusion
40-
The project is already in excellent condition and fully compliant with modern Python packaging standards. The only required action is the removal of the legacy `poetry.lock` file. No further refactoring is necessary.
40+
The project is already in excellent condition and fully compliant with modern Python packaging standards. No further refactoring is necessary.
4141

4242
## Phase 3: Conformance Verification
4343

4444
- **[X] Standards Compliance and Configuration**: `pyproject.toml` is the primary source of truth, the `[build-system]` is correctly configured, and all legacy configuration files have been removed.
4545
- **[X] Structure and Discoverability**: The project utilizes the `src` layout, and the build backend is correctly configured to discover packages.
46-
- **[X] Build Integrity**: The package builds successfully into both sdist and wheel formats using `python3 -m build`. The generated artifacts correctly include the source code, `LICENSE`, and `README` files.
46+
- **[X] Build Integrity**: The package builds successfully into both sdist and wheel formats using `uv build`. The generated artifacts correctly include the source code, `LICENSE`, and `README` files.
4747
- **[X] Installation and Testing**: The package can be installed in a fresh virtual environment and in editable mode. The test suite runs successfully against the installed package.

CI_CD_STRATEGY.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ This document outlines the CI/CD architecture for this project, including the Do
44

55
## CI/CD Architecture
66

7-
The CI/CD pipeline is built using GitHub Actions and is divided into two workflows: `ci.yml` and `docker.yml`.
7+
The CI/CD pipeline is built using GitHub Actions and is divided into two workflows: `ci-cd.yml` and `docker.yml`.
88

9-
- **`ci.yml`**: This workflow is triggered on `push` and `pull_request` events to the `main` and `develop` branches. It consists of two jobs:
9+
- **`ci-cd.yml`**: This workflow is triggered on `push` and `pull_request` events to the `main` and `develop` branches. It consists of two jobs:
1010
1. **`lint`**: This job runs the `pre-commit` suite to ensure all code adheres to the defined quality and style standards.
11-
2. **`test`**: This job runs the `pytest` suite across a matrix of Python versions (3.10, 3.11, and 3.12) to ensure the code is working as expected. It depends on the `lint` job, so it will only run if the linting passes.
11+
2. **`test`**: This job runs the `pytest` suite across a matrix of Python versions (Python 3.14 and 3.14t (free-threading)) to ensure the code is working as expected. It depends on the `lint` job, so it will only run if the linting passes.
1212

1313
- **`docker.yml`**: This workflow is triggered on `push` events to the `main` and `develop` branches. It builds, scans, and pushes a Docker image to the GitHub Container Registry.
1414

1515
## Docker Strategy
1616

1717
The `Dockerfile` is a multi-stage build to create a lean and secure production image.
1818

19-
- **Stage 1 (Builder)**: This stage installs Poetry, exports the project dependencies to a `requirements.txt` file, and installs them. It also installs the application itself.
20-
- **Stage 2 (Runtime)**: This stage uses a slim Python base image, creates a non-root user, and copies the installed dependencies and application from the builder stage. This results in a smaller and more secure final image.
19+
- **Stage 1 (Builder)**: This stage installs `uv`, uses it to sync project dependencies via `uv sync`, and builds the application into a wheel (`uv build`), leveraging BuildKit caching.
20+
- **Stage 2 (Runtime)**: This stage uses a slim Python 3.14 base image, creates a non-root user, and installs the wheel using `uv pip` from the builder stage. This results in a smaller and more secure final image.
2121

2222
## Security Measures
2323

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"author_email": "gowtham.rao@coreason.ai",
88
"license_contributor": "CoReason, Inc.",
99
"contact_email": "gowtham.rao@coreason.ai",
10-
"copyright_year": "2025"
10+
"copyright_year": "2026"
1111
}

hooks/post_gen_project.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,28 @@
1818
print("Initializing Git repository...")
1919

2020
try:
21-
# On Windows, shell=True is required to resolve commands like 'poetry' if they are batch files
21+
# On Windows, shell=True is required to resolve commands like 'uv' if they are batch files
2222
# or not strictly executables. On POSIX, shell=False is preferred.
2323
use_shell = sys.platform == "win32"
2424

2525
# Initialize git
2626
subprocess.run(["git", "init", "-b", "main"], check=True, shell=use_shell)
27+
28+
# Install dependencies and generate uv.lock BEFORE committing
29+
print("\nInstalling dependencies with uv...")
30+
subprocess.run(["uv", "sync", "--all-extras", "--dev"], check=True, shell=use_shell)
31+
32+
# Stage and commit all files (including the newly generated uv.lock)
2733
subprocess.run(["git", "add", "."], check=True, shell=use_shell)
2834
subprocess.run(
2935
["git", "commit", "-m", "Initial commit from cookiecutter"],
3036
check=True,
3137
shell=use_shell,
3238
)
3339

34-
# Install dependencies
35-
print("\nInstalling dependencies with Poetry...")
36-
subprocess.run(["poetry", "install"], check=True, shell=use_shell)
37-
38-
print("\nSuccessfully initialized git repo and installed dependencies.")
40+
print("\nSuccessfully initialized git repo, generated lockfile, and committed.")
3941
print("Your new project is ready at:", os.getcwd())
4042

4143
except Exception as e:
4244
print(f"\nAn error occurred during post-generation setup: {e}")
43-
print("Please manually run 'git init' and 'poetry install'.")
45+
print("Please manually run 'uv sync --all-extras --dev' and commit the results.")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See AGENTS.md for AI agent rules.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See AGENTS.md for AI agent rules.

{{cookiecutter.project_slug}}/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ __pycache__/
66
docs/
77
.github/
88
.pre-commit-config.yaml
9+
!uv.lock
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.py]
12+
indent_size = 4
13+
14+
[*.{yml,yaml,json,toml}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GitHub CODEOWNERS
2+
# For detail see: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
3+
4+
* @{{ cookiecutter.github_username }}
5+
6+
# Architectural constraints
7+
/.github/workflows/ @{{ cookiecutter.github_username }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See AGENTS.md for AI agent rules.

0 commit comments

Comments
 (0)