fix(setup): prune skill renders for hosts a checkout does not serve, without losing a file (#1694)

Every ./setup now removes the render dirs of hosts missing from the
installed-hosts record, so an install that rendered every host (632
SKILL.md, 34.7 MB under ~/.claude/skills/gstack) converges on its own
hosts. It runs per install, so two installs sharing one state root are
both cleaned, and never touches a recorded host, so ./setup --host codex
keeps a --host factory render.

The rules follow bin/gstack-relink: a symlink into the checkout (STRONG)
is removed; a file proven generated (WEAK: gen-skill-docs' banner, the
generator's exact openai.yaml shape, byte identity with the checkout, or
setup's runtime pointers naming it) is moved to
$GSTACK_STATE_ROOT/backups/host-renders/<ts>-<id>/; any other file,
including a link outside the checkout or bin/dev-setup's link to the
checkout itself, stays where it is. Only directories left empty are
removed. setup prints each kept path and a per-host summary, and
prune.log in the backup lists every path. A tree with nothing left to
remove is silent, so reruns print nothing.

gstack-upgrade/migrations/v1.91.50.0.sh records the hosts an existing
install serves and runs the same prune; a checkout no install points at
is left alone. The Hermes, OpenClaw and GBrain hints say to add the host
to the record before rendering it by hand.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-08 08:28:00 +00:00
1 parent f2012f3ab3
commit ecb13a5d5e
4 files changed
+295

No files matched your search

+12
View File
@@ -255,6 +255,7 @@ case "$HOST" in
echo "To integrate gstack with OpenClaw:"
echo " 1. Tell your OpenClaw agent: 'install gstack for openclaw'"
echo " 2. Or generate artifacts: bun run gen:skill-docs --host openclaw"
echo " (in an install, add 'openclaw' to .gstack-installed-hosts first, or ./setup prunes them)"
echo " 3. See docs/OPENCLAW.md for the full architecture"
print_instruction_tier
exit 0 ;;
@@ -268,6 +269,8 @@ case "$HOST" in
echo " 2. Render Hermes-flavoured skills yourself (not certified; #2826):"
echo " bun run gen:skill-docs --host hermes"
echo " then point a Hermes profile's skills.external_dirs at .hermes/skills."
echo " Add 'hermes' to .gstack-installed-hosts in this checkout first: ./setup"
echo " prunes renders of hosts that file does not name (#1694)."
print_instruction_tier
exit 0 ;;
gbrain)
@@ -278,6 +281,7 @@ case "$HOST" in
echo ""
echo "To generate brain-aware skills:"
echo " bun run gen:skill-docs --host gbrain"
echo " (in an install, add 'gbrain' to .gstack-installed-hosts first, or ./setup prunes them)"
echo ""
echo "GBrain setup and brain skills ship from the GBrain repo."
echo ""
@@ -3613,6 +3617,14 @@ if [ "$INSTALL_CODEX" -eq 1 ]; then
_setup_arm_publish codex "$_CX_SCOPE" "$_CX_PROJECT" "$CODEX_SKILLS" "$CODEX_GSTACK" - "${_CODEX_RENDER_ROOT:-committed}"
fi
# 7b. Prune the skill renders of hosts this checkout does not serve (#1694),
# on every run, so each install converges on its own recorded hosts even when
# several installs share one state root. Generated files go to the state
# root's backups; anything not proven generated stays in place.
if ! gstack_prune_host_renders "$SOURCE_GSTACK_DIR"; then
echo " warning: some generated host renders could not be backed up, so they were left in place; the next ./setup retries" >&2
fi
# 8. Run pending version migrations
# Migrations handle state fixes that ./setup alone can't cover (stale config,
# orphaned files, directory structure changes). Each migration is idempotent.