Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions scripts/armonia-workstation
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,27 @@ while [ $# -gt 0 ]; do case "$1" in
say() { printf ' %s\n' "$*"; }
head_() { printf '\n== %s ==\n' "$*"; }

# Code repos: the extension, the design authority, the skill library, the fork.
CODE=(amicode amico amico-plugin opencode)
# Code repos: the extension, the design authority. `amico` was renamed to
# `amicissimo` (cloned into the `amicissimo` directory, which mode_cards.ts and
# WORKSTATION.md expect). `amico-plugin` is archived and `opencode` is a retired
# fork (engine source is packages/app-bundle/overlay/); see harmoniqs/amicode#2135.
CODE=(amicode amicissimo)
# DEFAULT_SKILL_ROOTS — package skills resolve as <pkg>.jl/skills/<name>/SKILL.md
# IntonatoQICK.jl is archived (harmoniqs/amicode#2135) and intentionally not cloned.
PKGS=(Piccolo.jl Piccolissimo.jl DirectTrajOpt.jl NamedTrajectories.jl Intonato.jl
Intonatissimo.jl IntonatoQICK.jl Altissimo.jl Legato.jl Legatissimo.jl
Intonatissimo.jl Altissimo.jl Legato.jl Legatissimo.jl
HarmoniqsBenchmarks.jl PiccoloMultidocs.jl CuQuantum.jl JuliaStaticData.jl
jl2py pypiccolo)
# Distiller demo-ingest root.
# Distiller demo-ingest root. embedded-operators-demo is archived (#2135), dropped.
DEMO_REPOS=(atoms-demo atom-transport-demo braket-testing cloud-demo cryocmos-spin-demo
embedded-operators-demo fluxonium-demo ions kerr-readout-stanford nv-center-demo
fluxonium-demo ions kerr-readout-stanford nv-center-demo
nyu-bosonic-demo nyu-multiqubit-demo spin-qubit-demo stanford-bosonics
syndrome-extraction-demo)
# Renamed, archived or retired checkouts a workstation built before #2135 still
# carries. Reported as STALE (never deleted); --check exits nonzero if any exist.
STALE_DIRS=("$HQ/amico" "$HQ/amico-plugin" "$HQ/opencode"
"$HQ/packages/IntonatoQICK.jl" "$HQ/demos/embedded-operators-demo")
STALE=0

clone_into() { # <dest-dir> <repo>
local dest="$1/$2"
Expand All @@ -60,6 +69,15 @@ if [ "$DEMOS" = 1 ]; then
for r in "${DEMO_REPOS[@]}"; do clone_into "$HQ/demos" "$r"; done
fi

head_ "Stale checkouts from the pre-#2135 layout (reported, never removed)"
for p in "${STALE_DIRS[@]}"; do
if [ -d "$p" ]; then
STALE=$((STALE + 1))
say "STALE $p (renamed/archived/retired — remove by hand; not touched)"
fi
done
[ "$STALE" -eq 0 ] && say "ok none"

head_ "Vault mounts -> $VAULTS"
# Canonical state lives HERE, not in ~/harmoniqs. ~/harmoniqs/armonia is only a
# view symlink onto this root (armonia-init's rule: "never the canonical state").
Expand Down Expand Up @@ -123,3 +141,7 @@ if [ -d "$HQ/amicode" ]; then
fi

printf '\nDone.%s\n' "$([ "$CHECK" = 1 ] && echo ' (--check: nothing was changed)')"

# --check must not pass a machine that still carries the old layout.
[ "$CHECK" = 1 ] && [ "$STALE" -gt 0 ] && exit 1
exit 0
50 changes: 50 additions & 0 deletions tests/test_armonia_workstation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Fixture for scripts/armonia-workstation clone lists (harmoniqs/amicode#2135).
# Renamed / archived / retired repos must not be cloned, and --check on a
# machine carrying the old layout must report the stale directories instead of
# passing. Two fake roots only; no network (--check) and no real $HOME touched.
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WS="$HERE/../scripts/armonia-workstation"
[ -x "$WS" ] || { echo "FAIL: $WS not executable"; exit 1; }
fail() { echo "FAIL: $*"; exit 1; }

SB="$(mktemp -d)"; trap 'rm -rf "$SB"' EXIT
export HOME="$SB/home"; mkdir -p "$HOME"

# --- 1. static clone lists -------------------------------------------------
# Extract the three arrays from the script without executing its main body.
# Only the array bodies, with comments stripped: a comment mentioning a retired
# name must not count as the name being cloned.
BODY="$(sed -n '/^CODE=(/,/syndrome-extraction-demo)/p' "$WS" | sed 's/#.*$//')"
[ -n "$BODY" ] || fail "could not locate the CODE/PKGS/DEMO_REPOS arrays"
CODE_BODY="$(grep -E '^CODE=\(' "$WS" | sed 's/#.*$//')"
echo "$CODE_BODY" | grep -qw 'amicissimo' || fail "CODE must clone amicissimo"
echo "$CODE_BODY" | grep -qw 'amico' && fail "CODE must not clone the renamed amico repo"
echo "$CODE_BODY" | grep -qw 'amico-plugin' && fail "CODE must drop archived amico-plugin"
echo "$CODE_BODY" | grep -qw 'opencode' && fail "CODE must drop retired opencode fork"
echo "$BODY" | grep -qw 'IntonatoQICK.jl' && fail "archived IntonatoQICK.jl must be dropped from PKGS"
echo "$BODY" | grep -qw 'embedded-operators-demo' && fail "archived embedded-operators-demo must be dropped from DEMO_REPOS"

# --- 2. --check on an empty machine: amicissimo is the clone target ---------
OUT="$(HARMONIQS_ROOT="$SB/hq-empty" AMICO_VAULTS_ROOT="$SB/vaults-empty" bash "$WS" --check 2>&1)"
echo "$OUT" | grep -q 'MISSING amicissimo' || fail "--check on an empty machine must report MISSING amicissimo"
echo "$OUT" | grep -qE 'MISSING (amico|amico-plugin|opencode)$' && fail "--check must not expect the retired/renamed repos"

# --- 3. --check on the OLD layout must not pass ----------------------------
HQ="$SB/hq-old"
for d in amico amico-plugin opencode; do mkdir -p "$HQ/$d/.git"; done
mkdir -p "$HQ/packages/IntonatoQICK.jl/.git" "$HQ/demos/embedded-operators-demo/.git"
set +e
OUT="$(HARMONIQS_ROOT="$HQ" AMICO_VAULTS_ROOT="$SB/vaults-empty" bash "$WS" --check 2>&1)"
RC=$?
set -e
[ "$RC" -ne 0 ] || fail "--check on the old layout must exit nonzero (stale dirs), got 0"
for d in "$HQ/amico" "$HQ/amico-plugin" "$HQ/opencode" "$HQ/packages/IntonatoQICK.jl" "$HQ/demos/embedded-operators-demo"; do
echo "$OUT" | grep -q "STALE" && echo "$OUT" | grep -q "$d" || fail "--check must report stale directory $d"
done

# --- 4. --check must never delete anything ----------------------------------
[ -d "$HQ/amico/.git" ] && [ -d "$HQ/opencode/.git" ] || fail "--check must not remove stale checkouts"

echo "PASS: armonia-workstation clone lists (amicissimo in, retired/archived out; --check flags stale layout)"
Loading