agents/ci.md
For comprehensive guidelines, read these files:
| Topic | Read |
|---|---|
| Build commands and restrictions | agents/docs/build-system.md |
| Python coding standards | agents/docs/python-standards.md |
| Testing commands | agents/docs/testing-commands.md |
| MCP server tools | agents/docs/mcp-tools.md |
| Debugging strategies | agents/docs/debugging.md |
This file contains only CI-directory-specific guidelines.
Python Code Execution:
uv run python tmp.py (never just python)from ci.ci.module for ci.ci modules, from ci.module for top-level ci modulesExample:
# tmp.py (created in project root)
from ci.ci.clang_compiler import Compiler # CORRECT import path
from running_process import RunningProcess # NEVER use bare subprocess
result = RunningProcess.run(['git', 'status'], check=False, timeout=10, capture_output=True, text=True)
print(result.stdout)
Then run: uv run python tmp.py
Restrictions:
uv run python ci/ci-compile.py uno --examples Blinkuv run python with existing scripts🚨 ALWAYS USE bash lint - DO NOT RUN INDIVIDUAL LINTING SCRIPTS
bash lint./lint-js, ./check-js, python3 scripts/enhance-js-typing.pyuv run ruff check, uv run black, individual toolsWHY: bash lint provides comprehensive coverage of Python, C++, JavaScript, and enhancement analysis.
CAN USE FINE-GRAINED LINTING FOR SPECIFIC NEEDS
Background agents may use individual linting scripts when needed:
./lint-js - JavaScript-only linting./check-js - JavaScript type checkingpython3 scripts/enhance-js-typing.py - JavaScript enhancement analysisuv run ruff check - Python linting onlylint_code tool - Programmatic accessBUT STILL PREFER bash lint FOR COMPREHENSIVE CHECKING
1. Generate Profiler (if doesn't exist):
bash profile <function>
# Example: bash profile sincos16
This creates tests/profile/profile_<function>.cpp - a TEMPLATE that must be customized:
2. Customize Profiler:
Edit tests/profile/profile_<function>.cpp to:
volatile prevents optimization3. Build & Run Benchmarks:
# Local (20 iterations, release mode)
bash profile <function>
# Docker (consistent environment, recommended)
bash profile <function> --docker
# More iterations for better statistics
bash profile <function> --docker --iterations 50
# With callgrind analysis (requires valgrind)
bash profile <function> --docker --callgrind
4. Analyze Results: Results are automatically parsed and saved:
profile_<function>_results.json - Raw data (all iterations)profile_<function>_results.ai.json - Statistical summaryRead the .ai.json file for:
5. Create Optimization Variant:
sincos16_optimized)6. Validate Accuracy:
7. Report Recommendation:
User: "Optimize sincos16 with profile-guided optimization"
AI Steps:
1. bash profile sincos16 --docker --iterations 30
2. [Reads profile_sincos16_results.ai.json]
→ Median: 47.8 ns/call
3. [Analyzes bottlenecks - maybe via callgrind]
→ LUT bandwidth bottleneck identified
4. [Creates sincos16_optimized with smaller LUT]
5. bash profile sincos16_optimized --docker --iterations 30
6. [Results: 38.1 ns/call]
→ Speedup: 20% faster (47.8 → 38.1 ns/call)
7. [Validates accuracy with generated tests]
→ Max error: 1 (within tolerance)
8. [Recommends: Apply optimization]
→ Performance: 20% faster
→ Accuracy: Preserved
→ Memory: Reduced 50% (1KB → 0.5KB LUT)
Directory: tests/profile/
profile_<function>.cpp - Generated profiler (template, needs customization)Build Integration:
tests/test_config.py)tests/profile/meson.buildManual Build:
# Build without running
uv run test.py profile_<function> --cpp --build-mode release --build
# Run manually
.build/meson-release/tests/profile_<function>.exe baseline
⚠️ Don't use bash test for profilers - profile tests are NOT unit tests and should be run via bash profile.
For Linker Issues:
For Compiler Issues:
For Build Performance:
Always Use uv run python - NEVER just python or uv run:
python -c "..."uv run -c "..."uv run python -c "..."Correct Import Paths:
from ci.ci.clang_compiler import ... (for ci.ci modules)from ci.clang_compiler import ... (for top-level ci modules, if they exist)Never Change Directory:
cd ci && python ...cd ci/ci && python ...uv run python ci/script.pyGit-Bash Terminal Compatibility: Use leading space for git-bash compatibility:
bash test (note the leading space)bash test (may get truncated to ash test)🚨 ALL AGENTS: Read relevant agents/docs/*.md files before concluding CI/build work to refresh memory about current build system rules and requirements.