Skip to content

Commit ff88a3a

Browse files
agent-primers cleanup
1 parent 021025e commit ff88a3a

5 files changed

Lines changed: 182 additions & 182 deletions

File tree

agent-primers/ci-workflow.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The CI workflows trigger on:
3030

3131
### Workflow Jobs
3232

33-
#### 1. **Lint and Analysis Job** (Implemented)
33+
#### 1. Lint and Analysis Job
3434
- **Runner**: `ubuntu-latest`
3535
- **Purpose**: Fast feedback on code quality
3636
- **File**: `.github/workflows/test.yml`
@@ -43,7 +43,7 @@ The CI workflows trigger on:
4343
- `nix run .#rust-analysis`
4444
- `nix run .#python-analysis`
4545

46-
#### 2. **Test Job** (Implemented)
46+
#### 2. Test Job
4747
- **Runner**: `ubuntu-latest`
4848
- **Purpose**: Comprehensive testing across all environments
4949
- **File**: `.github/workflows/test.yml`
@@ -63,7 +63,7 @@ The CI workflows trigger on:
6363
- `pytest -m cli` (pytest-cli devshell)
6464
- Generate documentation: `nix run .#python-docs`
6565

66-
#### 3. **Build htty-core Wheels Job** (Matrix Strategy) (Implemented)
66+
#### 3. Build htty-core Wheels Job (Matrix Strategy)
6767
- **Purpose**: Build htty-core wheels for multiple architectures
6868
- **File**: `.github/workflows/release.yml` (job: `build-htty-core-wheels`)
6969
- **Matrix Dimensions**:
@@ -97,7 +97,7 @@ The CI workflows trigger on:
9797
- Test wheel installation and functionality (native builds only)
9898
- Upload wheel as artifact
9999

100-
#### 4. **Build htty Source Distribution Job** (Implemented)
100+
#### 4. Build htty Source Distribution Job
101101
- **Purpose**: Build htty pure Python source distribution
102102
- **File**: `.github/workflows/release.yml` (job: `build-htty-sdist`)
103103
- **Steps**:
@@ -106,7 +106,7 @@ The CI workflows trigger on:
106106
- Build htty source distribution: `nix build .#htty-sdist`
107107
- Upload source distribution as artifact
108108

109-
#### 5. **Publish to PyPI Job** (Implemented)
109+
#### 5. Publish to PyPI Job
110110
- **Runner**: `ubuntu-latest`
111111
- **File**: `.github/workflows/release.yml` (job: `publish-to-pypi`)
112112
- **Dependencies**: Requires successful completion of both `build-htty-core-wheels` and `build-htty-sdist` jobs
@@ -123,27 +123,27 @@ The CI workflows trigger on:
123123

124124
### Cross-Compilation Implementation
125125

126-
#### Current State (Implemented)
126+
#### Current State
127127
The `nix/packages/htty-core-wheel.nix` has been enhanced to support cross-compilation for all target architectures using maturin best practices.
128128

129129
#### Implemented Features in `htty-core-wheel.nix`
130130

131-
1. **Target system parameter** (✅ Implemented):
131+
1. Target system parameter:
132132
```nix
133133
{ inputs, pkgs, targetSystem ? null, ... }:
134134
```
135135

136-
2. **Cross-compilation detection** (✅ Implemented):
136+
2. Cross-compilation detection:
137137
- Detects when `targetSystem` is different from `pkgs.stdenv.hostPlatform.system`
138138
- Sets up appropriate Rust target mapping
139139
- Configures Rust toolchain with required targets
140140

141-
3. **Maturin with Zig cross-compilation** (✅ Implemented):
142-
- Uses `maturin build --zig` for cross-compilation (following maturin best practices)
141+
3. Maturin with Zig cross-compilation:
142+
- Uses `maturin build --zig` for cross-compilation
143143
- Automatic cross-compilation toolchain via Zig
144144
- No manual GCC/linker configuration needed
145145

146-
4. **Target platform mappings** (✅ Implemented):
146+
4. Target platform mappings:
147147
```nix
148148
rustTargetMap = {
149149
"aarch64-linux" = "aarch64-unknown-linux-gnu";
@@ -153,16 +153,16 @@ The `nix/packages/htty-core-wheel.nix` has been enhanced to support cross-compil
153153
};
154154
```
155155

156-
### CI Infrastructure (Implemented)
156+
### CI Infrastructure
157157

158-
#### Nix Setup and Caching (✅ Implemented)
158+
#### Nix Setup and Caching
159159
- **File**: `.github/actions/setup-nix/action.yml`
160160
- Uses `nixbuild/nix-quick-install-action@v30` for Nix installation
161161
- Uses `nix-community/cache-nix-action@v6` for Nix store caching
162162
- Cache key: `nix-store-${{ runner.os }}-${{ hashFiles('**/flake.lock') }}`
163163
- Garbage collection: Keep store under 8GB before caching
164164

165-
#### Artifact Management (✅ Implemented)
165+
#### Artifact Management
166166
- Upload each htty-core wheel with platform-specific artifact names (`htty-core-wheel-{system}`)
167167
- Upload htty source distribution as separate artifact (`htty-sdist`)
168168
- Merge all artifacts in the publish job using `merge-multiple: true`
@@ -175,33 +175,33 @@ The `nix/packages/htty-core-wheel.nix` has been enhanced to support cross-compil
175175
- Both packages should maintain synchronized versions
176176
- CI should validate version consistency across packages
177177

178-
#### Publishing Strategy (✅ Implemented)
178+
#### Publishing Strategy
179179
- **htty-core**: Publish architecture-specific wheels for each supported platform (4 wheels)
180180
- **htty**: Publish single source distribution that depends on htty-core (1 sdist)
181-
- Uses PyPI's trusted publishing with OIDC for secure, keyless publishing
181+
- Uses PyPI's trusted publishing with OIDC for keyless publishing
182182
- Supports dry-run mode for testing releases
183183

184-
#### Supported Platforms (✅ Implemented)
185-
Following the same strategy as polars and other Rust-based Python packages:
184+
#### Supported Platforms
185+
Builds packages for these platforms:
186186
- **Linux**: x86_64, aarch64 (cross-compiled with maturin --zig)
187187
- **macOS**: x86_64 (Intel), aarch64 (Apple Silicon)
188188
- **Windows**: Not currently supported (can be added later)
189189

190-
### Security and Best Practices (✅ Implemented)
190+
### Security and Best Practices
191191

192-
#### Trusted Publishing (✅ Implemented)
192+
#### Trusted Publishing
193193
- Uses PyPI's trusted publishing instead of API tokens
194194
- Requires GitHub repository to be configured as trusted publisher in PyPI
195195
- Uses `id-token: write` permission for OIDC authentication
196196
- Environment: `release` for additional protection
197197

198-
#### Artifact Verification (✅ Implemented)
198+
#### Artifact Verification
199199
- Verifies expected number of packages (4 wheels + 1 sdist)
200200
- Tests wheel installation on native platforms before publishing
201201
- Shows package details and sizes before publishing
202202
- Validates artifact completeness across matrix builds
203203

204-
#### Secrets Management (✅ Implemented)
204+
#### Secrets Management
205205
- No API keys or tokens stored in repository
206206
- All authentication handled via OIDC trusted publishing
207207
- Cross-compilation tooling (Zig) installed via Nix packages
@@ -226,7 +226,7 @@ Following the same strategy as polars and other Rust-based Python packages:
226226

227227
### ✅ Completed Implementation
228228

229-
All major phases of the CI workflow have been successfully implemented:
229+
All major phases of the CI workflow have been implemented:
230230

231231
#### Phase 1: Cross-Compilation Setup (✅ Complete)
232232
- ✅ Enhanced `nix/packages/htty-core-wheel.nix` with cross-compilation support
@@ -246,7 +246,7 @@ All major phases of the CI workflow have been successfully implemented:
246246
- ✅ PyPI trusted publishing configuration
247247
- ✅ Dry-run support for testing releases
248248

249-
### 🚧 Remaining Work
249+
### Remaining Work
250250

251251
#### Phase 2: Version Management System (Future Enhancement)
252252
- Create `nix/lib/version.nix` as single source of truth for version information
@@ -259,14 +259,14 @@ All major phases of the CI workflow have been successfully implemented:
259259
- Additional platforms (Windows support)
260260
- Additional quality gates (coverage, benchmarks, security scanning)
261261

262-
### 🎯 Current Status
262+
### Current Status
263263

264-
The CI workflow is **fully functional and ready for production use**. It provides:
264+
The CI workflow is functional. It provides:
265265

266-
- ✅ **Comprehensive testing** across all environments on every PR
267-
- ✅ **Multi-architecture builds** with cross-compilation
268-
- ✅ **Secure PyPI publishing** with trusted publishing
269-
- ✅ **Two-package distribution** (htty-core + htty)
270-
- ✅ **Dry-run capabilities** for testing releases
266+
- Testing across all environments on every PR
267+
- Multi-architecture builds with cross-compilation
268+
- PyPI publishing with trusted publishing
269+
- Two-package distribution (htty-core + htty)
270+
- Dry-run capabilities for testing releases
271271

272-
The implementation follows maturin best practices and mirrors successful Rust-Python projects like polars, ensuring reliable and efficient CI/CD for the htty project.
272+
The implementation uses maturin for building Python wheels with Rust components.

agent-primers/codegen.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## Overview
44

5-
The htty project uses [Cog](https://nedbatchelder.com/code/cog/) for automated code generation to maintain consistency across multiple languages (Rust, Python) and file formats (TOML, source files). This ensures that constants and version information stay synchronized throughout the codebase.
5+
The htty project uses [Cog](https://nedbatchelder.com/code/cog/) for automated code generation to maintain consistency across multiple languages (Rust, Python) and file formats (TOML, source files). Constants and version information are synchronized throughout the codebase.
66

77
## Architecture
88

99
### Central Source Files
1010

11-
The code generation system is driven by two central Nix files that serve as the single source of truth:
11+
The code generation system is driven by two central Nix files:
1212

1313
#### 1. `nix/lib/version.nix` - Version Management
1414
Contains all version-related information for the project:
@@ -30,9 +30,9 @@ Contains all version-related information for the project:
3030
}
3131
```
3232

33-
**Key Features:**
34-
- Single source of truth for all version information
35-
- Automatic git SHA integration
33+
Features:
34+
- Central version information
35+
- Git SHA integration
3636
- Python PEP 440 compatible prerelease format
3737
- Package-specific version formatting
3838

@@ -61,10 +61,10 @@ Contains all shared constants used across the codebase:
6161
}
6262
```
6363

64-
**Key Features:**
65-
- Centralized configuration for the entire project
64+
Features:
65+
- Centralized configuration for the project
6666
- Language-agnostic constant definitions
67-
- Comprehensive documentation with usage references
67+
- Documentation with usage references
6868
- Consistent naming conventions
6969

7070
### Code Generation Process
@@ -91,7 +91,7 @@ Used to import constants from Nix environment variables:
9191
//[[[end]]]
9292
```
9393

94-
**Purpose**: Loads constants from environment variables into Cog variables for use in generation blocks.
94+
Purpose: Loads constants from environment variables into Cog variables for use in generation blocks.
9595

9696
### Code Generation Block
9797

@@ -107,7 +107,7 @@ pub const DEFAULT_TERMINAL_ROWS: u16 = 30;
107107
//[[[end]]]
108108
```
109109

110-
**Purpose**: Generates the actual code that gets compiled/executed. The content between the block markers is automatically updated.
110+
Purpose: Generates the actual code that gets compiled/executed. The content between the block markers is automatically updated.
111111

112112
### Version Block (Simple)
113113

@@ -122,32 +122,32 @@ version = "0.2.1-dev202507140024"
122122
# [[[end]]]
123123
```
124124

125-
**Purpose**: Inserts version strings into configuration files.
125+
Purpose: Inserts version strings into configuration files.
126126

127127
## File Types and Patterns
128128

129129
### Rust Files (`*.rs`)
130130

131-
**Comments**: Use `//` and `/**/` comment styles
132-
**Pattern**: Import environment variables, then generate constants
133-
**Example files**:
131+
Comments: Use `//` and `/**/` comment styles
132+
Pattern: Import environment variables, then generate constants
133+
Example files:
134134
- `htty-core/src/rust/constants.rs` - Project constants
135135
- `htty-core/src/rust/cli.rs` - Version info for `--version` flag
136136

137137
### Python Files (`*.py`)
138138

139-
**Comments**: Use `#` comment style
140-
**Pattern**: Similar to Rust but with Python syntax
141-
**Example files**:
139+
Comments: Use `#` comment style
140+
Pattern: Similar to Rust but with Python syntax
141+
Example files:
142142
- `htty/src/htty/constants.py` - Project constants
143143
- `htty/src/htty/cli.py` - Version info for `--version` flag
144144
- `htty/src/htty/__init__.py` - Module version
145145

146146
### Configuration Files (`*.toml`)
147147

148-
**Comments**: Use `#` comment style
149-
**Pattern**: Simple version insertion, no complex logic
150-
**Example files**:
148+
Comments: Use `#` comment style
149+
Pattern: Simple version insertion, no complex logic
150+
Example files:
151151
- `htty-core/Cargo.toml` - Rust package version
152152
- `htty-core/pyproject.toml` - Python package version (htty-core)
153153
- `htty/pyproject.toml` - Python package version (htty)
@@ -189,7 +189,7 @@ The Nix build system automatically converts constants to environment variables:
189189

190190
### Constants Files
191191

192-
**Rust**: `htty-core/src/rust/constants.rs`
192+
Rust: `htty-core/src/rust/constants.rs`
193193
```rust
194194
// Terminal configuration
195195
pub const DEFAULT_TERMINAL_COLS: u16 = 60;
@@ -199,7 +199,7 @@ pub const DEFAULT_TERMINAL_ROWS: u16 = 30;
199199
pub const COORDINATION_DELAY: Duration = Duration::from_millis(200);
200200
```
201201

202-
**Python**: `htty/src/htty/constants.py`
202+
Python: `htty/src/htty/constants.py`
203203
```python
204204
# Terminal configuration
205205
DEFAULT_TERMINAL_COLS = 60
@@ -211,14 +211,14 @@ COORDINATION_DELAY_MS = 200
211211

212212
### Version Files
213213

214-
**Cargo.toml**:
214+
Cargo.toml:
215215
```toml
216216
[package]
217217
name = "htty_core"
218218
version = "0.2.1-dev202507140024"
219219
```
220220

221-
**Python __init__.py**:
221+
Python __init__.py:
222222
```python
223223
__version__ = "0.2.1-dev202507140024"
224224
```
@@ -234,20 +234,20 @@ Generated content is between Cog markers:
234234
//[[[end]]]
235235
```
236236

237-
**Always edit the source Nix files instead:**
237+
Always edit the source Nix files instead:
238238
- Edit `nix/lib/version.nix` for version changes
239239
- Edit `nix/lib/constants.nix` for constant changes
240240
- Run `nix run .#codegen` to regenerate
241241

242242
### Avoiding Cog Conflicts
243243

244-
**Problem**: Type annotations with nested brackets can confuse Cog:
244+
Problem: Type annotations with nested brackets can confuse Cog:
245245
```python
246246
# This breaks Cog because it ends with ]]]
247247
actions: list[tuple[str, Optional[str]]] = []
248248
```
249249

250-
**Solution**: Use type aliases:
250+
Solution: Use type aliases:
251251
```python
252252
# At module level
253253
ActionTuple: TypeAlias = tuple[str, Optional[str]]
@@ -258,12 +258,12 @@ actions: list[ActionTuple] = []
258258

259259
### Version Format Requirements
260260

261-
**Python**: Must follow PEP 440
262-
- `0.2.1-dev202507140024` (prerelease with timestamp)
263-
- `0.2.1` (stable release)
261+
Python: Must follow PEP 440
262+
- `0.2.1-dev202507140024` (prerelease with timestamp)
263+
- `0.2.1` (stable release)
264264
-`0.2.1-2025-July-14-00-24` (month names not allowed)
265265

266-
**Rust**: More flexible, but we use same format for consistency
266+
Rust: More flexible, but we use same format for consistency
267267

268268
### Environment Variable Access
269269

0 commit comments

Comments
 (0)