Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# TwisteRL

A hybrid Rust/Python Reinforcement Learning framework optimized for speed.

## Project Overview

- **Rust (`rust/`)**: Core RL logic—environment stepping, trajectory collection, inference.
- **Python (`src/twisterl/`)**: Training loop, neural network optimization (PyTorch).

## Setup & Build Commands

```bash
# Install (editable mode, compiles Rust extension)
pip install -e .

# Rust check
cd rust && cargo check && cargo test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cd rust && ... command changes the current directory. If a user is copying commands one by one, they will end up in the rust directory, which might not be the intention for subsequent commands. To make the commands safer to copy-paste, consider running the directory-specific commands in a subshell. This ensures the user's shell session remains in the project root.

Suggested change
cd rust && cargo check && cargo test
(cd rust && cargo check && cargo test)


# Python tests
pytest tests/
```

## Code Style & Conventions

- **Rust**: Use `cargo fmt` and `cargo clippy` before committing.
- **Python**: PEP 8. Type hints encouraged.
- **Checkpoints**: Always use `safetensors` (never pickle `.pt`).
- **Symmetry**: Implement `TwistableEnv` for environments with symmetries.

## Testing Instructions

```bash
# Full Python test suite
pytest tests/

# Rust unit tests
cd rust && cargo test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the setup command, this cd command changes the current directory. Using a subshell makes it safer for users to run these commands from the project root without unexpectedly changing their working directory.

Suggested change
cd rust && cargo test
(cd rust && cargo test)


# End-to-end training check
python -m twisterl.train --config examples/ppo_puzzle8_v1.json
```

## Directory Structure

```
twisteRL/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The project's package name is twisterl (as defined in pyproject.toml and rust/Cargo.toml). The directory structure diagram uses twisteRL/ as the root directory name, which is inconsistent. It should be twisterl/ to accurately reflect the project's naming.

Suggested change
twisteRL/
twisterl/

├── rust/ # Rust crate (core RL)
│ ├── src/ # Rust source
│ └── Cargo.toml # Rust deps
├── src/twisterl/ # Python package
├── tests/ # Python tests
├── examples/ # Configs and notebooks
└── pyproject.toml # Python build config
Comment on lines +47 to +53

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comments in the directory structure diagram are not vertically aligned, which slightly impacts readability. Aligning them would make the diagram cleaner and easier to parse visually.

Suggested change
├── rust/ # Rust crate (core RL)
│ ├── src/ # Rust source
│ └── Cargo.toml # Rust deps
├── src/twisterl/ # Python package
├── tests/ # Python tests
├── examples/ # Configs and notebooks
└── pyproject.toml # Python build config
├── rust/ # Rust crate (core RL)
│ ├── src/ # Rust source
│ └── Cargo.toml # Rust deps
├── src/twisterl/ # Python package
├── tests/ # Python tests
├── examples/ # Configs and notebooks
└── pyproject.toml # Python build config

```

## Dev Environment Tips

- **Hybrid Build**: `pip install -e .` rebuilds the Rust extension.
- **Performance**: Prefer Rust for hot paths; Python for flexibility.
- **Traits**: `twisterl::rl::env::Env` is the core environment trait.
Loading