feat(admin-config-tool): task 1.3 - nix and xce-build.sh integration

Add python3 + pycapnp/pyyaml/jsonschema/click/pytest/ruff (+pip) to the
nix dev shell, wire a new `xceadmin` case into xce-build.sh (schema
sync from src/schema/ and src/configs/schema/, pip install by profile,
pytest), package-data config so bundled schemas survive a non-editable
install, xce-build SKILL.md docs, and ruff format/check hooks matching
this repo's stdin-JSON hook convention (not brief.md's env-var sketch,
which would have silently no-op'd).

Verified live end-to-end inside `nix develop ./src` for both the
default (editable) and release (pinned) profiles; found and fixed 3
real bugs along the way (missing pip, PEP 668 externally-managed-
environment, missing package-data for release-profile bundling) —
logged as bug-1458/1459/1460.

Requirements: 5.5, 8.1, 8.2, 8.6
This commit is contained in:
Rongsong Shen 2026-07-22 03:57:43 +00:00
parent 2e4ef4e209
commit 798f19b83a
7 changed files with 92 additions and 5 deletions

View file

@ -49,7 +49,7 @@ cd "$SRC_DIR"
usage() {
echo "Usage: $0 [component] [profile|build_dir] [build_dir]"
echo "Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli"
echo "Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli, xceadmin"
echo "Profiles: asan (default), debug (non-ASAN -O0 -g3, for gdb/cores), release"
exit 1
}
@ -112,6 +112,43 @@ case "$COMPONENT" in
cd frontend/xcecli && CGO_ENABLED=0 go test ./... -count=1
fi
;;
xceadmin)
# Python — no meson, dispatched by this case statement alone (design
# review correction: xceadmin is deliberately NOT wired into
# src/meson.build/meson.options, see .kiro/specs/admin-config-tool/
# design.md, File Structure Plan). Ignores $BUILD_DIR/$MESON_OPTS;
# $PROFILE only selects editable vs. pinned pip install below.
XCEADMIN_DIR="$SRC_DIR/xceadmin"
SCHEMA_DST="$XCEADMIN_DIR/src/xcecommon/schema_files"
echo "=== Syncing xceadmin bundled schemas ==="
mkdir -p "$SCHEMA_DST/json"
cp "$SRC_DIR/schema/controller.capnp" "$SCHEMA_DST/controller.capnp"
cp "$SRC_DIR/schema/c.capnp" "$SCHEMA_DST/c.capnp"
cp "$SRC_DIR/configs/schema/"*.schema.json "$SCHEMA_DST/json/"
cd "$XCEADMIN_DIR"
# nix's python3 site-packages lives under the read-only /nix/store,
# so `pip install` (editable or pinned) can't target it directly —
# it refuses with "externally-managed-environment" (PEP 668). Use a
# throwaway venv that inherits the nix-provided pycapnp/pyyaml/
# jsonschema/click/pytest (--system-site-packages) so pip only ever
# has to install xceadmin itself, never rebuild those from PyPI.
# Recreated on every invocation for a clean, reproducible install —
# same philosophy as setup_build's `rm -rf "$BUILD_DIR"` above.
VENV_DIR="$XCEADMIN_DIR/.venv"
rm -rf "$VENV_DIR"
python3 -m venv --system-site-packages "$VENV_DIR"
if [ "$PROFILE" = "release" ]; then
echo "=== Building xceadmin Python package (pinned, non-editable) ==="
"$VENV_DIR/bin/pip" install . --quiet
else
echo "=== Building xceadmin Python package (editable) ==="
"$VENV_DIR/bin/pip" install -e . --quiet
fi
echo "=== Running xceadmin tests ==="
"$VENV_DIR/bin/python" -m pytest tests/ -v
echo "=== Done: xceadmin (profile=$PROFILE) ==="
exit 0
;;
all)
setup_build
echo "=== Building all components ==="