Skip to content

Commit b0e4a38

Browse files
committed
Expand AGENTS docs to multi-level structure
1 parent 3611e85 commit b0e4a38

File tree

8 files changed

+134
-54
lines changed

8 files changed

+134
-54
lines changed

.github/AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# AGENTS.md — .github/
2+
3+
CI/CD workflows and repo automation.
4+
5+
## Workflows (source of truth)
6+
- `conda-package.yml` — Intel channel conda build/test pipeline
7+
- `conda-package-cf.yml` — conda-forge-oriented build/test pipeline
8+
- `build-with-clang.yml` — clang compatibility checks
9+
- `build-docs.yml` — docs build pipeline
10+
11+
## Policy
12+
- Treat workflow YAML as canonical for platform/Python matrices.
13+
- Keep artifact naming and channel usage aligned with workflow files.
14+
- Avoid doc claims about CI coverage unless present in workflow config.

.github/copilot-instructions.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11
# GitHub Copilot Instructions — mkl_random
22

33
## Identity
4-
You are an expert Python/C developer working on `mkl_random` at Intel.
5-
Apply Intel engineering standards: correctness first, minimal diffs, no assumptions.
4+
You are an expert Python/C/Cython developer working on `mkl_random` at Intel.
5+
Prioritize correctness, numerical/statistical integrity, and minimal diffs.
66

77
## Source of truth
88
This file is canonical for Copilot/agent behavior.
9-
`AGENTS.md` provides project context.
9+
`AGENTS.md` files provide project context.
1010

1111
## Precedence
1212
copilot-instructions > nearest AGENTS > root AGENTS
13-
Higher-precedence file overrides; lower must not restate overridden guidance.
13+
Higher-precedence file overrides lower-precedence context.
1414

1515
## Mandatory flow
1616
1. Read root `AGENTS.md`. If absent, stop and report.
17-
2. For edited files, use root AGENTS (no local AGENTS files exist here).
18-
3. If future local `AGENTS.md` files appear, find nearest per file.
17+
2. For each edited file, locate and follow the nearest `AGENTS.md`.
18+
3. If no local file exists, inherit from root `AGENTS.md`.
1919

2020
## Contribution expectations
21-
- Keep diffs minimal; prefer atomic single-purpose commits.
22-
- Preserve `numpy.random` API compatibility by default.
23-
- For API changes: update tests + docstrings when user-visible.
24-
- For bug fixes: add regression tests in `mkl_random/tests/`.
25-
- Do not generate code without a corresponding test update in the same step.
26-
- Run `pre-commit run --all-files` if `.pre-commit-config.yaml` exists.
21+
- Keep changes atomic and single-purpose.
22+
- Preserve `numpy.random` compatibility by default.
23+
- For behavior changes: update/add tests in `mkl_random/tests/` in the same change.
24+
- For bug fixes: include a regression test.
25+
- Run `pre-commit run --all-files` when `.pre-commit-config.yaml` is present.
2726

2827
## Authoring rules
29-
- Use source-of-truth files for all mutable details.
30-
- Never invent/hardcode versions, flags, or matrix values.
31-
- Use stable entry points: `pip install -e .` (dev), `pytest mkl_random/tests` (test).
32-
- Never include sensitive data in any file.
33-
- **Cython/MKL calls:** Release GIL with `with nogil:` blocks for RNG operations (they are thread-safe in MKL).
34-
- **Memory:** Ensure proper alignment for RNG state structures; respect MKL object lifecycle.
35-
- **BRNG selection:** Do not hardcode BRNG (basic RNG) names outside `__init__.py` or tests.
28+
- Never invent versions, build flags, CI matrices, or channel policies.
29+
- Use source-of-truth files for mutable details.
30+
- Do not hardcode BRNG behavior outside intended API/configuration points.
31+
- Prefer stable local entry points:
32+
- `python -m pip install -e .`
33+
- `pytest mkl_random/tests`
3634

3735
## Source-of-truth files
3836
- Build/config: `pyproject.toml`, `setup.py`
39-
- Dependencies: `pyproject.toml` (dependencies, optional-dependencies), `conda-recipe/meta.yaml`, `conda-recipe-cf/meta.yaml`
37+
- Dependencies: `pyproject.toml`, `conda-recipe/meta.yaml`, `conda-recipe-cf/meta.yaml`
4038
- CI: `.github/workflows/*.{yml,yaml}`
41-
- API contracts: `mkl_random/__init__.py`, NumPy `random` docs (https://numpy.org/doc/stable/reference/random/index.html)
42-
- Test data: `mkl_random/tests/`
39+
- API: `mkl_random/__init__.py`, `mkl_random/mklrand.pyx`
40+
- Tests: `mkl_random/tests/`
4341

4442
## Intel-specific constraints
45-
- Package channels: Intel PyPI (https://software.repos.intel.com/python/pypi), Intel conda (https://software.repos.intel.com/python/conda), conda-forge
46-
- MKL backend: requires `mkl-devel` at build time, `mkl` at runtime
47-
- Statistical properties: preserve distribution correctness; no RNG changes without validation
48-
- Do not hardcode MKL version assumptions; respect `pyproject.toml` `requires-python` range
43+
- Build-time MKL: `mkl-devel`; runtime MKL: `mkl`
44+
- Preserve statistical properties for distribution/BRNG-related changes
45+
- Do not claim performance/statistical improvements without reproducible validation

AGENTS.md

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
# AGENTS.md — mkl_random
22

3-
## What this project is
4-
NumPy-based Python interface to Intel® oneMKL Random Number Generation (RNG) functionality. Provides MKL-accelerated random sampling from distributions compatible with `numpy.random`. Part of Intel® Distribution for Python. Archetype: **python** (Cython + C extensions).
5-
6-
Layers: Python interface, Cython bindings (`mklrand.pyx`), C backend (`src/`).
7-
8-
## How it's structured
9-
- `mkl_random/` — main package
10-
- `mklrand.pyx` — Cython RNG interface
11-
- `src/` — C code generation scripts
12-
- `tests/` — pytest suite
13-
- `conda-recipe/`, `conda-recipe-cf/` — Intel/conda-forge builds
14-
- `examples/` — parallel MC, random states demos
15-
16-
Build: `pyproject.toml` + `setup.py`. Runtime: `mkl`, `numpy>=1.26.4`.
3+
Entry point for agent context in this repo.
174

18-
## How to work in it
19-
- Keep changes atomic and single-purpose.
20-
- Preserve `numpy.random` API compatibility; document divergence in commit message.
21-
- Pair changes with tests and docstrings.
22-
- Never assume MKL or NumPy versions; use source-of-truth files.
23-
- **RNG specifics:** Changes to BRNG (basic RNG) selection or distribution methods must preserve statistical properties.
24-
- **Local dev:** `conda create -n dev python numpy cython mkl-devel pytest && pip install -e .`
25-
26-
For agent policy: `.github/copilot-instructions.md`
5+
## What this project is
6+
`mkl_random` is a NumPy-compatible random module backed by Intel® oneMKL RNG.
7+
It provides accelerated random sampling with API compatibility goals relative to `numpy.random`.
8+
9+
## Key components
10+
- **Python package:** `mkl_random/`
11+
- **Cython layer:** `mkl_random/mklrand.pyx`
12+
- **C backend/templates:** `mkl_random/src/`
13+
- **Tests:** `mkl_random/tests/`
14+
- **Packaging:** `conda-recipe/`, `conda-recipe-cf/`
15+
- **Examples:** `examples/`
16+
17+
## Build/runtime basics
18+
- Build system: `pyproject.toml` + `setup.py`
19+
- Build deps: `cython`, `numpy`, `mkl-devel`
20+
- Runtime deps: `numpy`, `mkl`
21+
22+
## Development guardrails
23+
- Preserve `numpy.random` API compatibility unless change is explicitly requested.
24+
- RNG changes must preserve statistical correctness and reproducibility expectations.
25+
- Keep diffs minimal and pair behavior changes with tests.
26+
- Avoid hardcoding mutable versions/matrices/channels in docs.
2727

2828
## Where truth lives
2929
- Build/config: `pyproject.toml`, `setup.py`
30-
- Dependencies: `pyproject.toml` (`dependencies`, `optional-dependencies`), `conda-recipe/meta.yaml`, `conda-recipe-cf/meta.yaml`
31-
- CI: `.github/workflows/`
32-
- API/contracts: `mkl_random/__init__.py`, NumPy `random` docs
33-
- Stable entry points: `python -m pip install .`, `pytest mkl_random/tests`
30+
- Dependencies: `pyproject.toml`, `conda-recipe*/meta.yaml`
31+
- CI matrices/workflows: `.github/workflows/*.{yml,yaml}`
32+
- Public API: `mkl_random/__init__.py`
33+
- Tests: `mkl_random/tests/`
34+
35+
For behavior policy, see `.github/copilot-instructions.md`.
3436

3537
## Directory map
36-
No local AGENTS files — project is small enough for root-level guidance only.
38+
Use nearest local `AGENTS.md` when present:
39+
- `.github/AGENTS.md` — CI workflows and automation policy
40+
- `mkl_random/AGENTS.md` — package-level implementation context
41+
- `mkl_random/tests/AGENTS.md` — testing scope and conventions
42+
- `conda-recipe/AGENTS.md` — Intel-channel conda packaging
43+
- `conda-recipe-cf/AGENTS.md` — conda-forge recipe context
44+
- `examples/AGENTS.md` — runnable examples and expected behavior

conda-recipe-cf/AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# AGENTS.md — conda-recipe-cf/
2+
3+
Conda-forge recipe context for `mkl_random`.
4+
5+
## Scope
6+
- conda-forge specific `meta.yaml` and build scripts in this directory.
7+
8+
## Guardrails
9+
- Keep conda-forge recipe semantics separate from Intel-channel recipe.
10+
- Align recipe changes with `conda-package-cf.yml` workflow behavior.

conda-recipe/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGENTS.md — conda-recipe/
2+
3+
Intel-channel conda packaging context.
4+
5+
## Scope
6+
- `meta.yaml` — package metadata and dependency pins
7+
- `build.sh` / `bld.bat` — platform build scripts
8+
9+
## Guardrails
10+
- Treat recipe files as canonical for build/runtime dependency intent.
11+
- Keep recipe updates synchronized with CI workflow expectations.
12+
- Do not infer platform/Python matrix from docs; read workflow YAML.

examples/AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# AGENTS.md — examples/
2+
3+
Runnable usage examples for `mkl_random`.
4+
5+
## Intent
6+
- Demonstrate practical usage patterns (parallel MC, random states, etc.).
7+
- Serve as quick sanity checks, not exhaustive correctness/performance tests.
8+
9+
## Guardrails
10+
- Keep examples concise and runnable.
11+
- If API behavior in examples changes, keep comments/output expectations consistent.

mkl_random/AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# AGENTS.md — mkl_random/
2+
3+
Core package implementation for MKL-backed random functionality.
4+
5+
## Key files
6+
- `__init__.py` — public package exports/API wiring
7+
- `mklrand.pyx` — Cython bindings to MKL RNG support
8+
- `_init_helper.py` — platform/runtime loading helpers
9+
- `src/` — C-level support and generation assets
10+
- `tests/` — package tests (see local AGENTS in tests)
11+
12+
## Guardrails
13+
- Preserve `numpy.random`-compatible behavior by default.
14+
- RNG algorithm/distribution changes must preserve statistical correctness.
15+
- Keep BRNG/distribution behavior explicit and test-covered.
16+
- Prefer minimal, isolated edits around touched API paths.

mkl_random/tests/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGENTS.md — mkl_random/tests/
2+
3+
Test suite for RNG behavior, API compatibility, and regressions.
4+
5+
## Expectations
6+
- Behavior changes in package code should include test updates in the same PR.
7+
- Add regression tests for bug fixes.
8+
- Keep tests deterministic when possible (fixed seeds / stable assertions).
9+
- For statistical assertions, use robust criteria and document rationale.
10+
11+
## Entry point
12+
- `pytest mkl_random/tests`

0 commit comments

Comments
 (0)