From c8e0f65a399dac135919f3ccf376c062a422f57a Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Sat, 30 May 2026 08:13:59 +0800 Subject: [PATCH] enhance xce-build skill --- .claude/skills/xce-build/SKILL.md | 11 ++--- CLAUDE.md | 18 ++++--- src/controller/CLAUDE.md | 4 +- src/lib/CLAUDE.md | 6 +-- src/scheduler/CLAUDE.md | 4 +- src/tools/xce-build.sh | 82 +++++++++++++++++++++++++++++++ src/worker/CLAUDE.md | 4 +- 7 files changed, 107 insertions(+), 22 deletions(-) create mode 100755 src/tools/xce-build.sh diff --git a/.claude/skills/xce-build/SKILL.md b/.claude/skills/xce-build/SKILL.md index 6930c11..4aba838 100644 --- a/.claude/skills/xce-build/SKILL.md +++ b/.claude/skills/xce-build/SKILL.md @@ -1,6 +1,6 @@ --- name: xce-build -description: Build the xce source code +description: "Build XCE components with tests. Usage: /xce-build [component] [build_dir]. Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli" context: fork disable-model-invocation: true allowed-tools: Bash(*) @@ -9,12 +9,9 @@ allowed-tools: Bash(*) ## build xce source code ```bash -BUILD_DIR="$0" - -if [ -z "$BUILD_DIR" ]; then - BUILD_DIR=xce.build -fi +COMPONENT="$0" +BUILD_DIR="$1" cd src && \ - nix develop --command "rm -Rf $BUILD_DIR && meson setup $BUILD_DIR --buildtype=debug -Db_sanitize=address && meson compile -C $BUILD_DIR" + nix develop --command bash tools/xce-build.sh ${COMPONENT:+$COMPONENT} ${BUILD_DIR:+$BUILD_DIR} ``` diff --git a/CLAUDE.md b/CLAUDE.md index cb7f10e..6b5ddbf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,20 +8,26 @@ This project uses OpenWolf for context management. Read and follow .wolf/OPENWOL # XCE Cluster Management System ## Overview -XCE is an HPC cluster management system providing job scheduling, queue management, and cluster resource control. The Go-based API/CLI tier fronts C/C++ system daemons (controller, worker, scheduler). +XCE is an HPC cluster management system providing job scheduling, queue management, and cluster resource control. The Go-based API/CLI tier fronts C system daemons (controller, worker, scheduler). ## Tech Stack - **Go 1.23.4**: REST API server (`src/frontend/apiserver`), CLI tool (`src/frontend/xcecli`) -- **C/C++**: Core daemons — controller, worker, scheduler, shared lib +- **C (gnu17)**: Core daemons — controller, worker, scheduler, shared lib - **Build**: Meson + Nix flakes for C components; `make` for Go components - **Go key deps**: Gin v1.10.0, JWT v4, Zap logging, Viper config, Cobra CLI ## Development Commands ```bash -# Full dev build — all components (debug + ASAN) -/xce-build # Preferred: builds everything via nix develop + meson +# Build with /xce-build skill (debug + ASAN, clean build, runs tests) +/xce-build # Build all components + run all tests +/xce-build lib # Build libxce + run lib tests +/xce-build controller # Build lib + controller + run controller tests +/xce-build scheduler # Build lib + scheduler + run scheduler tests +/xce-build worker # Build lib + worker (no unit tests registered) +/xce-build apiserver # Build lib + apiserver + xcecli + run Go unit tests +/xce-build xcecli # Build xcecli only + run xcecli Go tests -# From src/frontend/ +# From src/frontend/ (manual Go dev loop) make build-server # Build apiserver binary → /tmp/apiserver make build-cli # Build xcecli binary → /tmp/xce_static (CGO_ENABLED=0) make test # Unit tests (no live server required) @@ -156,7 +162,7 @@ Kiro-style Spec-Driven Development on an agentic SDLC - `/kiro-spec-design {feature} [-y]` - `/kiro-validate-design {feature}` (optional: design review) - `/kiro-spec-tasks {feature} [-y]` -- Phase 2 (Implementation): `/kiro-spec-impl {feature} [tasks]` +- Phase 2 (Implementation): `/kiro-impl {feature} [tasks]` - `/kiro-validate-impl {feature}` (optional: after implementation) - `/kiro-verify-completion {feature}` — validate all acceptance criteria are met - Debugging: `/kiro-debug {feature}` — systematic debugging with spec context diff --git a/src/controller/CLAUDE.md b/src/controller/CLAUDE.md index be22b50..7cb5dff 100644 --- a/src/controller/CLAUDE.md +++ b/src/controller/CLAUDE.md @@ -20,7 +20,7 @@ Core source files handle distinct domains: Links against `libxce` from `src/lib/`. ## Conventions -- C standard: C99 or later +- C standard: gnu17 - Format with `clang-format` - Component-specific headers in `include/` - Shared types defined in `src/include/xce/` (libxce) @@ -31,4 +31,4 @@ Links against `libxce` from `src/lib/`. ## See Also - Shared library: `src/lib/CLAUDE.md` -- Root guidelines: `/workspace/CLAUDE.md` +- Root guidelines: `CLAUDE.md` (repo root) diff --git a/src/lib/CLAUDE.md b/src/lib/CLAUDE.md index 7c69972..c490508 100644 --- a/src/lib/CLAUDE.md +++ b/src/lib/CLAUDE.md @@ -12,12 +12,12 @@ meson build && ninja -C build ## Architecture - Produces `libxce.a` (static) and/or `libxce.so` (shared) -- Linked by all C/C++ system components: controller, worker, scheduler +- Linked by all C system components: controller, worker, scheduler - Public headers exposed via `src/include/xce/` - Test suite in `src/lib/testsuite/` ## Conventions -- C standard: C99 or later +- C standard: gnu17 - Format with `clang-format` (config at repo root if present) - All public API headers go in `src/include/xce/` — not in `src/lib/` - Implementation files stay in `src/lib/` @@ -27,4 +27,4 @@ meson build && ninja -C build - `src/lib/testsuite/` — Library unit tests ## See Also -- Root guidelines: `/workspace/CLAUDE.md` +- Root guidelines: `CLAUDE.md` (repo root) diff --git a/src/scheduler/CLAUDE.md b/src/scheduler/CLAUDE.md index 1f859a0..af67813 100644 --- a/src/scheduler/CLAUDE.md +++ b/src/scheduler/CLAUDE.md @@ -18,11 +18,11 @@ meson build && ninja -C build Links against `libxce` from `src/lib/`. ## Conventions -- C standard: C99 or later +- C standard: gnu17 - Format with `clang-format` - New scheduling policies → add as a plugin under `src/plugins/`, do not modify the core engine - Shared types defined in `src/include/xce/` (libxce) ## See Also - Shared library: `src/lib/CLAUDE.md` -- Root guidelines: `/workspace/CLAUDE.md` +- Root guidelines: `CLAUDE.md` (repo root) diff --git a/src/tools/xce-build.sh b/src/tools/xce-build.sh new file mode 100755 index 0000000..c8f4708 --- /dev/null +++ b/src/tools/xce-build.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +set -euo pipefail + +COMPONENT="${1:-all}" +BUILD_DIR="${2:-xce.build}" + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SRC_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + +cd "$SRC_DIR" + +usage() { + echo "Usage: $0 [component] [build_dir]" + echo "Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli" + exit 1 +} + +setup_build() { + echo "=== Clean build: $BUILD_DIR ===" + rm -rf "$BUILD_DIR" + meson setup "$BUILD_DIR" --buildtype=debug -Db_sanitize=address +} + +case "$COMPONENT" in + lib) + setup_build + echo "=== Building lib + tests ===" + meson compile -C "$BUILD_DIR" xcelib_test + echo "=== Running lib tests ===" + meson test -C "$BUILD_DIR" "libxce test" --print-errorlogs + ;; + controller) + setup_build + echo "=== Building lib + controller + tests ===" + meson compile -C "$BUILD_DIR" xce_controller controller_unit_test + echo "=== Running controller tests ===" + meson test -C "$BUILD_DIR" --suite controller --print-errorlogs + ;; + scheduler) + setup_build + echo "=== Building lib + scheduler + tests ===" + meson compile -C "$BUILD_DIR" xce_scheduler sched_test + echo "=== Running scheduler tests ===" + "./$BUILD_DIR/scheduler/testsuite/sched_test" + ;; + worker) + setup_build + echo "=== Building lib + worker ===" + meson compile -C "$BUILD_DIR" xcecd xcecd_worker xrun + echo "=== Worker built (no unit tests registered) ===" + ;; + apiserver) + setup_build + echo "=== Building lib + apiserver + xcecli ===" + meson compile -C "$BUILD_DIR" apiserver xcecli + echo "=== Running frontend Go unit tests ===" + cd frontend && make test + ;; + xcecli) + setup_build + echo "=== Building xcecli ===" + meson compile -C "$BUILD_DIR" xcecli + echo "=== Running xcecli Go unit tests ===" + cd frontend/xcecli && CGO_ENABLED=0 go test ./... -count=1 + ;; + all) + setup_build + echo "=== Building all components ===" + meson compile -C "$BUILD_DIR" + echo "=== Running all C tests ===" + meson test -C "$BUILD_DIR" --print-errorlogs + echo "=== Running scheduler test (manual) ===" + "./$BUILD_DIR/scheduler/testsuite/sched_test" + echo "=== Running frontend Go unit tests ===" + cd frontend && make test + ;; + *) + usage + ;; +esac + +echo "=== Done: $COMPONENT ===" diff --git a/src/worker/CLAUDE.md b/src/worker/CLAUDE.md index 34c1a5f..7d4d479 100644 --- a/src/worker/CLAUDE.md +++ b/src/worker/CLAUDE.md @@ -18,11 +18,11 @@ meson build && ninja -C build Links against `libxce` from `src/lib/`. ## Conventions -- C standard: C99 or later +- C standard: gnu17 - Format with `clang-format` - Headers in `include/` - Shared types defined in `src/include/xce/` (libxce) ## See Also - Shared library: `src/lib/CLAUDE.md` -- Root guidelines: `/workspace/CLAUDE.md` +- Root guidelines: `CLAUDE.md` (repo root)