Skip to content

Commit 3611e85

Browse files
committed
Add AGENTS.md and Copilot instructions
Introduce structured AI agent instructions following Intel's AGENTS spec v4: - AGENTS.md: project context (RNG interface, archetype, structure, source-of-truth) - .github/copilot-instructions.md: agent behavior policy Key guidance: - Preserve numpy.random API compatibility - RNG specifics: BRNG selection, statistical properties - Cython: release GIL for MKL RNG calls (thread-safe) - Local dev: conda env + pip install -e . - Statistical validation required for RNG changes Token budget: 217 words (AGENTS.md) + copilot-instructions Based on mkl_fft pattern
1 parent 5941905 commit 3611e85

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

.github/copilot-instructions.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# GitHub Copilot Instructions — mkl_random
2+
3+
## 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.
6+
7+
## Source of truth
8+
This file is canonical for Copilot/agent behavior.
9+
`AGENTS.md` provides project context.
10+
11+
## Precedence
12+
copilot-instructions > nearest AGENTS > root AGENTS
13+
Higher-precedence file overrides; lower must not restate overridden guidance.
14+
15+
## Mandatory flow
16+
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.
19+
20+
## 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.
27+
28+
## 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.
36+
37+
## Source-of-truth files
38+
- Build/config: `pyproject.toml`, `setup.py`
39+
- Dependencies: `pyproject.toml` (dependencies, optional-dependencies), `conda-recipe/meta.yaml`, `conda-recipe-cf/meta.yaml`
40+
- 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/`
43+
44+
## 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

AGENTS.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# AGENTS.md — mkl_random
2+
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`.
17+
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`
27+
28+
## Where truth lives
29+
- 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`
34+
35+
## Directory map
36+
No local AGENTS files — project is small enough for root-level guidance only.

0 commit comments

Comments
 (0)