Skip to content

Commit 72b9d13

Browse files
authored
Merge pull request #395 from uriahf/codex/repository-operating-rules
Document persistent repository operating rules
2 parents b429df1 + 773908a commit 72b9d13

1 file changed

Lines changed: 120 additions & 79 deletions

File tree

‎AGENTS.md‎

Lines changed: 120 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,159 @@
1-
# rtichoke Agent Information
1+
# rtichoke Python repository rules
22

3-
This document provides guidance for AI agents working on the `rtichoke` repository.
3+
## Role and ownership
4+
5+
This repository owns the Python implementation of rtichoke: Python statistical
6+
calculations and public APIs, performance-data preparation, evaluation and
7+
population metadata, canonical visualization adapters, immutable
8+
`rtichoke_viz` vendoring, browser-renderer consumer adoption, and Python tests,
9+
typing, linting, packaging, and documentation.
410

5-
## Development Environment
11+
It does not own shared TypeScript visualization contracts or renderers.
612

7-
To set up the development environment, follow these steps:
13+
## Start from fresh state
814

9-
1. **Install `uv`**.
10-
2. **Create a virtual environment** with `uv venv`.
11-
3. **Install development dependencies** with:
15+
Before modifying anything:
1216

13-
```bash
14-
uv sync --dev
15-
```
17+
1. Inspect actual current `main`, relevant open PRs, recent relevant merges, and
18+
tags or releases when relevant.
19+
2. Check whether equivalent work already exists.
20+
3. Inspect the repository's current scripts, tests, workflows, and conventions
21+
instead of relying on remembered commands or architecture.
1622

17-
## Running Tests
23+
If actual repository state materially contradicts the task assumptions, stop
24+
before broadening scope and report the discrepancy.
1825

19-
Run the test suite with:
26+
## Scope discipline
2027

21-
```bash
22-
uv run pytest
23-
```
28+
Make the smallest change required. During focused work, do not opportunistically
29+
redesign unrelated APIs, change statistics outside scope, modify
30+
`rtichoke_viz` source, expand summary-report behavior, introduce unrelated
31+
dependencies, or perform broad refactoring. Stop and report when a task requires
32+
a materially broader architectural or statistical decision.
2433

25-
## Coding Conventions
34+
Preserve existing public APIs and defaults unless explicitly requested. Static
35+
behavior must remain unchanged when adding time-dependent browser adoption. Do
36+
not add R-like APIs merely for cross-language symmetry, or add dependencies or
37+
breaking behavior without explicit scope.
2638

27-
### Functional Programming
39+
## Python conventions
2840

29-
Strive to use a functional programming style as much as possible. Avoid side effects and mutable state where practical.
41+
- Prefer Polars for production dataframe work and `uv` for environment and
42+
dependency workflows.
43+
- Prefer existing project patterns over new abstractions and a functional style
44+
where practical.
45+
- Do not introduce pandas as a direct production dependency unless the task
46+
explicitly requires it.
47+
- Give exported functions accurate NumPy-style docstrings.
48+
- Keep Ruff formatting and linting and `ty` type checking green.
3049

31-
### Docstrings
50+
## Statistical boundary
3251

33-
All exported functions must have NumPy-style docstrings. Great Docs parses these docstrings to generate the API reference, so parameter, return-value, and usage documentation should remain accurate and user-facing.
52+
Existing production statistical calculations are authoritative unless a task
53+
explicitly targets a statistical bug or methodology change. Browser and
54+
canonical-visualization adoption must consume already-computed production
55+
quantities rather than recomputing statistics in adapters.
3456

35-
Example:
57+
Do not change censoring logic, Aalen-Johansen logic, competing-risk handling, or
58+
cutoff semantics unless explicitly requested. Preserve established static and
59+
time-dependent cutoff behavior where they intentionally differ.
3660

37-
```python
38-
def my_function(param1, param2):
39-
"""Summary of the function's purpose.
61+
## Evaluation and reference identity
4062

41-
Parameters
42-
----------
43-
param1 : int
44-
Description of the first parameter.
45-
param2 : str
46-
Description of the second parameter.
63+
Preserve semantic identity:
4764

48-
Returns
49-
-------
50-
bool
51-
Description of the return value.
52-
"""
53-
return True
54-
```
65+
- Evaluation identity represents the semantic model/population evaluation.
66+
- Rendered-series geometry identity is distinct from evaluation identity.
67+
- Horizon is evaluation-context and geometry metadata, not a replacement for
68+
evaluation identity.
69+
- Reuse `_EvaluationMetadata` and related semantic infrastructure where
70+
appropriate.
71+
- Never infer population identity from numerical equality. Distinct populations
72+
remain distinct even when prevalence, event risk, or reference geometry is
73+
numerically equal.
5574

56-
## Pre-commit Hooks
75+
Use explicit semantic reference ownership. Scope population-dependent references
76+
by semantic population, and by `population × horizon` for time-dependent outputs
77+
when required. Multiple models sharing one population must share the same
78+
population-owned reference where semantics require it. Do not derive ownership
79+
from equal or unequal numeric values.
5780

58-
This repository uses pre-commit hooks for code quality and consistency, including `ruff-check`, `ruff-format`, and `uv-lock`.
81+
## Canonical visualization and renderers
5982

60-
Run them manually with:
83+
Canonical adapters map already-computed Python output into the shared contract.
84+
They must preserve semantic evaluation identity and reference ownership, create
85+
deterministic series geometry identity, carry horizon metadata where applicable,
86+
and avoid statistical recomputation. Extend the existing adapter architecture
87+
instead of creating parallel one-off implementations.
6188

62-
```bash
63-
pre-commit run --all-files
64-
```
89+
Plotly remains the default renderer unless a task explicitly changes public
90+
defaults. Canonical browser rendering remains opt-in unless explicitly changed.
91+
Reuse the established public renderer vocabulary and `RtichokeBrowserChart`
92+
infrastructure. Never silently change default output types.
93+
94+
## Immutable `rtichoke_viz` consumption
6595

66-
## Documentation
96+
Never consume `rtichoke_viz/main`; use only immutable, verified releases and the
97+
repository's established vendoring mechanism. Before vendoring a release,
98+
verify all of the following:
6799

68-
Documentation is built with Great Docs and Quarto.
100+
- tag and exact source commit;
101+
- archive filename and SHA-256 against the published checksum;
102+
- `MANIFEST` version and source commit;
103+
- required packaged JavaScript, CSS, and schema files;
104+
- required public renderer exports.
69105

70-
- Great Docs configuration: `great-docs.yml`
71-
- Narrative guides: `user_guide/`
72-
- Documentation dependencies: the `docs` dependency group in `pyproject.toml`
73-
- Local build: `uv sync --group docs` followed by `uv run great-docs build`
74-
- Pull requests receive a rendered preview under the repository's GitHub Pages site.
75-
- Merges to `main` publish the production documentation automatically.
106+
Never manually edit vendored renderer bytes. On upgrade, search the whole
107+
repository for stale version, tag, archive, and checksum pins, then synchronize
108+
all provenance records, tests, packaging assertions, and workflow guards.
76109

77-
Great Docs requires Python 3.11 or newer for documentation builds. This does not change the package's Python >=3.9 runtime support.
110+
## Validation
78111

79-
## Type Checking
112+
Before opening a PR, inspect the actual current scripts and workflows, run
113+
focused tests and the complete relevant validation suite, and do not weaken
114+
tests merely to make CI green. Run real-browser acceptance when browser rendering
115+
changes, and packaging and provenance guards when vendored assets change.
80116

81-
This project uses `ty` for type checking. Run:
117+
Current baseline commands include:
82118

83119
```bash
84-
uv run ty check src tests
120+
uv sync --all-extras --dev
121+
uv run ruff check .
122+
uv run ruff format --check .
123+
uv run ty check src/rtichoke
124+
uv run pytest tests
85125
```
86126

87-
## PR completion protocol
88-
89-
Do not consider an implementation task complete merely because code has been pushed or a pull request has been opened.
127+
Use the repository's actual current commands when they differ or when more
128+
focused validation is appropriate.
90129

91-
After creating or updating a pull request:
130+
## PR and release ownership
92131

93-
1. Inspect all required GitHub Actions checks for the current PR head.
94-
2. If checks are still running, re-check them while the session is active rather than handing the PR back to the user for manual monitoring.
95-
3. If a required check fails, inspect the failing job and logs and determine whether the failure is caused by the PR.
96-
4. If the fix is within the stated task scope, make the fix, push it, and inspect CI again.
97-
5. Repeat the diagnose/fix/re-check loop until all required checks pass or a genuine blocker requires user input.
132+
For mutation tasks:
98133

99-
Escalate to the user only when resolving the failure would require one or more of the following:
134+
1. Implement the focused change and validate it locally.
135+
2. Open one focused PR.
136+
3. Inspect GitHub Actions for the current PR head and, while the session is
137+
active, recheck jobs that are still running.
138+
4. Inspect failed job logs, fix in-scope failures, push, and repeat until green
139+
or genuinely blocked.
100140

101-
- changing frozen statistical semantics, contracts, or architecture;
102-
- broadening the agreed task scope;
103-
- weakening or removing a meaningful test or quality gate;
104-
- changing a public API or backward-compatibility promise beyond the task;
105-
- making a product or technical decision with multiple legitimate choices;
106-
- resolving an external service, permissions, infrastructure, or credential problem that the agent cannot fix safely.
141+
Do not ask the user to manually check CI. Escalate only when resolution requires
142+
a broader semantic, statistical, compatibility, dependency, product, or
143+
infrastructure decision. Do not merge unless explicitly instructed.
107144

108-
Routine failures such as lint errors, formatting errors, test regressions caused by the PR, snapshots/fixtures that legitimately need updating, packaging errors, documentation-build errors, and similar mechanical issues should be fixed without asking the user to manually inspect GitHub Actions.
145+
Do not publish Python package releases unless explicitly requested. Consumer
146+
adoption normally stops at an unmerged focused PR.
109147

110-
The final handoff should include:
148+
## Completion report
111149

112-
- pull request link;
113-
- final PR head commit;
114-
- tests/checks run locally when applicable;
115-
- final GitHub Actions status;
116-
- any remaining caveats or blockers.
150+
At the end of mutation work, report:
117151

118-
Do not ask the user to manually check whether CI passed.
152+
- starting `main`, final branch and head, and package version;
153+
- files changed;
154+
- statistical behavior changed or explicitly unchanged;
155+
- canonical identity and reference behavior;
156+
- vendored visualization provenance when applicable;
157+
- local validation and final CI status;
158+
- PR number, link, and state;
159+
- anything deliberately deferred.

0 commit comments

Comments
 (0)