Skip to content

Commit c001e0c

Browse files
authored
Devcontainer config and context for kiro-cli (Amazon) (#465)
* Devcontainer config and context for kiro-cli (Amazon) * Fix CMake config omission * Prevent pre-release versions of GitHub Copilot Chat
1 parent 96eda71 commit c001e0c

File tree

6 files changed

+524
-2
lines changed

6 files changed

+524
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"source=${localEnv:HOME}/.podman-proxy/podman.sock,target=/tmp/podman.sock,type=bind",
2424
"source=${localEnv:HOME}/.aws,target=/root/.aws,type=bind",
2525
"source=${localEnv:HOME}/.config/gh,target=/root/.config/gh,type=bind,readonly",
26-
"source=${localEnv:HOME}/.gnupg,target=/root/.gnupg,type=bind"
26+
"source=${localEnv:HOME}/.gnupg,target=/root/.gnupg,type=bind",
27+
"source=${localEnv:HOME}/.kiro,target=/root/.kiro,type=bind"
2728
],
2829
"initializeCommand": "bash .devcontainer/ensure-repos.sh",
2930
"onCreateCommand": "bash .devcontainer/setup-repos.sh /workspaces",
@@ -50,6 +51,7 @@
5051
"/opt/spack-environments/phlex-ci/.spack-env/view/lib/python/site-packages"
5152
],
5253
"cmake.defaultConfigurePreset": "default",
54+
"cmake.cmakePath": "${workspaceFolder}/.devcontainer/cmake_wrapper.sh",
5355
"cmake.ctestPath": "${workspaceFolder}/.devcontainer/ctest_wrapper.sh",
5456
"cmake.generator": "Ninja",
5557
"C_Cpp.default.cStandard": "c17",
@@ -58,7 +60,8 @@
5860
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
5961
"python.languageServer": "Pylance",
6062
"python.analysis.typeCheckingMode": "basic",
61-
"python.analysis.diagnosticMode": "workspace"
63+
"python.analysis.diagnosticMode": "workspace",
64+
"github.copilot-chat.usePreReleaseVersion": false
6265
},
6366
"extensions": [
6467
"charliermarsh.ruff",

.devcontainer/post-create.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ if command -v prek >/dev/null 2>&1; then
1717
elif command -v pre-commit >/dev/null 2>&1; then
1818
pre-commit install || true
1919
fi
20+
21+
# Install kiro-cli and set up shell integrations.
22+
curl -fsSL https://cli.kiro.dev/install | bash

.kiro/rules/guidelines.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Development Guidelines
2+
3+
## File Formatting — CRITICAL (applies to every file you create or edit)
4+
5+
- Files must end with exactly one newline (`\n`). No trailing blank lines, no
6+
trailing whitespace on any line (including blank lines within the file).
7+
- The final character must be `\n`; the character before it must not be `\n`
8+
or a space/tab.
9+
10+
## Language-Specific Formatting
11+
12+
### C++
13+
14+
- clang-format (`.clang-format`): 100-char line limit, 2-space indentation
15+
- clang-tidy (`.clang-tidy`): follow all recommendations
16+
- Header files: `.hpp`; implementation files: `.cpp`
17+
- Test files: `*_test.cpp` or descriptive names
18+
19+
### Python
20+
21+
- ruff for formatting and linting (`pyproject.toml`)
22+
- Google-style docstrings; 99-char line limit; double quotes; type hints
23+
- Test files: `test_*.py`
24+
- Do not name files after standard library modules (e.g., avoid `types.py`)
25+
26+
### CMake
27+
28+
- gersemi or cmake-format: `dangle_align: "child"`, `dangle_parens: true`
29+
30+
### Jsonnet
31+
32+
- jsonnetfmt for formatting; CI enforces this
33+
- Used for workflow configs in `test/` and elsewhere
34+
35+
### Markdown
36+
37+
- MD012: no multiple consecutive blank lines
38+
- MD022: headings surrounded by one blank line
39+
- MD031: fenced code blocks surrounded by one blank line
40+
- MD032: lists surrounded by one blank line
41+
- MD034: no bare URLs — use `[text](url)`
42+
- MD036: use `#` headings, not `**Bold**` for titles
43+
- MD040: always specify code block language
44+
45+
## Naming Conventions
46+
47+
### C++
48+
49+
- `lowercase_snake_case` for types, classes, functions, variables
50+
- `UPPER_CASE` for macros and constants
51+
- Namespaces: `phlex::` (core), `phlex::experimental::` (experimental)
52+
53+
### Python
54+
55+
- PEP 8; descriptive test function names
56+
57+
## Comments and Documentation
58+
59+
- Explain *why*, not *what* or *how* — code is self-documenting for those
60+
- No temporal markers (`NEW:`, `CHANGED:`) — git history tracks changes
61+
- Remove dead code; do not comment it out
62+
- If an expected feature is absent, explain why (e.g., "Single-threaded
63+
context; locks unnecessary")
64+
65+
## Git Workflow
66+
67+
### Branch Creation
68+
69+
Do not set upstream tracking at branch creation time:
70+
71+
```bash
72+
git checkout -b feature/my-feature # no --track
73+
git switch --no-track -c feature/my-feature # alternative
74+
```
75+
76+
Set tracking only when pushing for the first time:
77+
78+
```bash
79+
git push -u origin feature/my-feature
80+
```
81+
82+
### Pull Requests
83+
84+
- Pass all CI checks; follow coding guidelines
85+
- Minimize changes — keep PRs focused
86+
- If changes affect `phlex-examples`, create an issue there (or in `phlex`
87+
if not possible), and notify the user
88+
- If changes require documentation updates in `phlex-design`, create an issue
89+
there (or in `phlex` if not possible)
90+
- If changes affect Spack recipes in `phlex-spack-recipes`, create an issue
91+
there (or in `phlex` if not possible)
92+
93+
## Build and Test Workflow
94+
95+
### Environment Setup
96+
97+
Always source `setup-env.sh` before building or testing. This applies in all
98+
environments (devcontainer, local, HPC, CI containers):
99+
100+
```bash
101+
# Standalone repository
102+
. scripts/setup-env.sh
103+
104+
# Multi-project workspace (workspace root contains setup-env.sh)
105+
. srcs/phlex/scripts/setup-env.sh
106+
```
107+
108+
### Build
109+
110+
```bash
111+
# Preferred: use presets
112+
cmake --preset default -S . -B build
113+
ninja -C build
114+
115+
# Or manually
116+
cmake -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja
117+
cmake --build build -j $(nproc)
118+
```
119+
120+
### Test
121+
122+
```bash
123+
ctest --test-dir build -j $(nproc) --output-on-failure
124+
# With timeout guard (recommended):
125+
ctest --test-dir build -j $(nproc) --test-timeout 90
126+
# Run specific tests:
127+
ctest --test-dir build -R "regex"
128+
```
129+
130+
### Coverage
131+
132+
```bash
133+
# Complete workflow
134+
./scripts/coverage.sh all
135+
136+
# Step by step
137+
./scripts/coverage.sh setup test html view
138+
139+
# Via CMake targets (after coverage preset build)
140+
cmake --build build --target coverage-xml
141+
cmake --build build --target coverage-html
142+
```
143+
144+
### Pre-commit Hooks
145+
146+
```bash
147+
# Detect available tool
148+
PREKCOMMAND=$(command -v prek || command -v pre-commit || echo "")
149+
150+
# Install hooks (once per clone; automatic in devcontainer)
151+
$PREKCOMMAND install
152+
153+
# Run all hooks against all files (recommended before opening a PR)
154+
$PREKCOMMAND run --all-files
155+
156+
# Run against changed files only
157+
$PREKCOMMAND run
158+
159+
# Update hook revisions
160+
$PREKCOMMAND auto-update
161+
```
162+
163+
`prek` is installed in `phlex-dev`; not in `phlex-ci`. Fall back to invoking
164+
formatters directly if neither is available.
165+
166+
## Python Integration Details
167+
168+
- `PYTHONPATH` should include only paths containing user Python modules loaded
169+
by Phlex (source dir and build output dir). Do not append system/Spack/venv
170+
`site-packages`.
171+
- Type conversion in `plugins/python/src/modulewrap.cpp` uses substring
172+
matching on type names — this is brittle. Ensure converters exist for all
173+
types used in tests. Exact matches required (`numpy.float32 != float`).
174+
- Python test structure: C++ driver provides data streams, Jsonnet config
175+
wires the graph, Python script implements algorithms.
176+
177+
## Memory Management
178+
179+
- `std::shared_ptr` for shared ownership; `std::unique_ptr` for exclusive
180+
- Raw pointers only for non-owning references
181+
- Python/C++ interop: manual `Py_INCREF`/`Py_DECREF`; `PyGILRAII` for GIL
182+
- GC-tracked Python types: `Py_TPFLAGS_HAVE_GC`, implement `tp_traverse` and
183+
`tp_clear`, call `PyObject_GC_UnTrack` before deallocation
184+
185+
## Error Handling
186+
187+
- C++: `std::runtime_error` for runtime failures; propagate Python exceptions
188+
as `std::runtime_error`
189+
- Python C API: set exceptions with `PyErr_SetString`/`PyErr_Format`; return
190+
`nullptr` on error; clear with `PyErr_Clear()` when recovering
191+
192+
## External Software Versions
193+
194+
When specifying versions or commit hashes for external software (e.g., GitHub
195+
Actions), always verify against the official release source:
196+
197+
1. Check existing workflows in `.github/workflows/` for the version currently
198+
in use
199+
2. Verify whether a newer version exists at the official releases page
200+
3. The authoritative source always takes precedence over training data
201+
202+
## Platform-Specific Code
203+
204+
```cpp
205+
#if __linux__
206+
constexpr double mem_denominator{1e3};
207+
#else // AppleClang
208+
constexpr double mem_denominator{1e6};
209+
#endif
210+
```
211+
212+
Use POSIX APIs where available; document platform requirements.
213+
214+
## Searching Source Directories
215+
216+
If the workspace root contains a `srcs/` directory with symbolic links, always
217+
use `find -L` or `find -follow` to ensure linked directories are traversed.

.kiro/rules/product.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Product Overview
2+
3+
## Purpose
4+
5+
Phlex is a framework for **P**arallel, **h**ierarchical, and **l**ayered
6+
**ex**ecution of data-processing algorithms. It provides a graph-based
7+
execution engine for orchestrating complex data-processing workflows with
8+
automatic parallelization, hierarchical data organization, and layered
9+
algorithm execution.
10+
11+
## Repository Ecosystem
12+
13+
- **Primary**: `Framework-R-D/phlex` — this repository
14+
- **Design & docs**: `Framework-R-D/phlex-design`
15+
- **Coding guidelines**: `Framework-R-D/phlex-coding-guidelines`
16+
- **Examples**: `Framework-R-D/phlex-examples`
17+
- **Spack recipes**: `Framework-R-D/phlex-spack-recipes`
18+
- **Build system dependency**: `FNALssi/cetmodules`
19+
- **Container images**: `phlex-ci` (CI), `phlex-dev` (devcontainer / local dev)
20+
21+
## Key Features
22+
23+
- Graph-based workflow execution with automatic parallelization via Intel TBB
24+
- Algorithm types: providers, transforms, observers, filters, folds, unfolds
25+
- Hierarchical data processing with configurable data-layer hierarchies
26+
- Product store for type-safe data sharing between algorithms
27+
- Jsonnet-based workflow configuration
28+
- Python plugin support via C API (and optional cppyy)
29+
- Optional FORM integration for ROOT-based data persistence
30+
31+
## Target Users
32+
33+
Scientific computing researchers and data-pipeline engineers building
34+
parallel, hierarchical data-processing workflows — primarily in high-energy
35+
physics.
36+
37+
## Status
38+
39+
- Version: 0.1.0 (active development)
40+
- License: Apache 2.0
41+
- Repository: <https://github.com/Framework-R-D/phlex>
42+
- Coverage: tracked via Codecov

0 commit comments

Comments
 (0)