From c79826802e88f859ff9499b802c21f9a13402f1e Mon Sep 17 00:00:00 2001 From: Alex Ivantsov Date: Tue, 17 Nov 2026 19:37:54 -0500 Subject: [PATCH 1/2] chore(skills): remove the skill-mount mechanism SKILLS/VENDORED.tsv lost its last row in the previous release, yet the deployers still carried the step that cloned the public agent-skills repo and synced mirrors from it. The template ships its own harness skills in SKILLS/; an organization's shared skills are delivered separately by that organization. Removed: bin/skills-vendor.sh, SKILLS/VENDORED.tsv, and the suites skills-vendor-test.sh and deploy-skills-mount-test.sh. deploy.sh and deploy.ps1 no longer clone or sync. deploy.sh keeps its step numbers (docs and the session briefing cite steps 7 and 8); verify-ops.sh retires check 22 and keeps 23 to 25, drops skills-vendor.sh from the destructive-tool list, and checks 4 and 9b stop reading a manifest. The self-test and the Windows deploy test lose their mount cases, and CI stops installing rsync, which only those tests used. Existing copies keep their clone and mirrors because nothing deletes files; DEPLOYMENT.md, "Leftovers from the skill mounts", says how to recognise and remove them. --- .claude-config/bin/README.md | 18 +- .claude-config/bin/skills-vendor.sh | 535 -------------- .../bin/tests/deploy-rc-wiring-test.sh | 4 +- .../bin/tests/deploy-skills-mount-test.sh | 79 --- .../bin/tests/deploy-windows-test.ps1 | 117 +--- .../bin/tests/skills-vendor-test.sh | 660 ------------------ .claude-config/bin/verify-ops-selftest.sh | 27 +- .claude-config/bin/verify-ops.sh | 48 +- .claude-config/deploy.ps1 | 92 +-- .claude-config/deploy.sh | 81 +-- .claude-config/workflows/harness-audit.js | 2 +- .github/workflows/gate.yml | 7 +- .gitignore | 3 - AGENTS.md | 9 +- CHANGELOG.md | 24 + DEPLOYMENT.md | 62 +- PROJECTS/projects-map.md | 18 +- README.md | 43 +- SKILLS/README.md | 20 +- SKILLS/THIRD_PARTY_NOTICES.md | 5 +- SKILLS/VENDORED.tsv | 34 - 21 files changed, 109 insertions(+), 1779 deletions(-) delete mode 100755 .claude-config/bin/skills-vendor.sh delete mode 100755 .claude-config/bin/tests/deploy-skills-mount-test.sh delete mode 100755 .claude-config/bin/tests/skills-vendor-test.sh delete mode 100644 SKILLS/VENDORED.tsv diff --git a/.claude-config/bin/README.md b/.claude-config/bin/README.md index 43bef80..1c30374 100644 --- a/.claude-config/bin/README.md +++ b/.claude-config/bin/README.md @@ -90,7 +90,7 @@ digest (with an older indexer it falls back to the 24 KB `MEMORY.md` check), and 6b WARNs on a pool over 60 entries; both FAIL only when the indexer cannot run or cannot read a pool, because a pool's size is its owner's call. Check 9b WARNs on a `SKILL.md` over 16 KB or with a line over 1,500 characters, skipping -mounted, synced and symlinked skills. Check 5 reads a tracker project number +synced and symlinked skills. Check 5 reads a tracker project number (`P` plus 8 digits, a dot, 4 digits) as an ID, not a principle citation. Check 8 runs `secrets-scan.sh` over memory and lessons and reports its two failures apart: a found credential (exit 1), or a line grep could not scan (exit 2, @@ -410,22 +410,6 @@ once, and fails closed when `flock` is missing. Your own shell is not wrapped. Replaces the fleet's `claude-wrapper.sh`. Test: `tests/claude-root-wrapper-test.sh`. -## `skills-vendor.sh`: the skill mounts - -Mirrors each `SKILLS/VENDORED.tsv` row from its source clone under `PROJECTS/` -into `SKILLS//` (`sync`, the default), or reports drift (`--check`: OK, -DRIFT, MISSING; the gate behind `verify-ops.sh` check 22). Uses rsync with a -content comparison where installed and tar otherwise; either builds the mirror -in a temp dir and swaps it in, so a failed copy leaves the old one intact. Honors `OPS_DIR`. Deploy -clones the public source once and runs `sync`. It never deletes a folder it -did not write: `SKILLS/.vendored-state.tsv` records a digest of each mirror, -and a destination that is not a known mirror (your own skill under a mounted -name, a hand-edited mirror, any unrecorded folder that differs from its -source) is moved to -`.claude-config/backup/skills-replaced/-/` first, with a `BACKUP` -line naming the path, and moved back if the install fails. Test: -`tests/skills-vendor-test.sh`. - ## `mcp-http-call.py` and `await-approval`: scripts that talk to an MCP server Both are standard-library Python and carry no server name: where they talk is diff --git a/.claude-config/bin/skills-vendor.sh b/.claude-config/bin/skills-vendor.sh deleted file mode 100755 index da3ea3a..0000000 --- a/.claude-config/bin/skills-vendor.sh +++ /dev/null @@ -1,535 +0,0 @@ -#!/usr/bin/env bash -# skills-vendor.sh - mount the shared skill source(s) into OPS/SKILLS. -# -# OPS mounts portable technique skills rather than carrying a drifting fork of -# each (SKILLS/README.md § "Skill sources"). This script IS that mount: the skill -# repos cloned under PROJECTS/ are the source of truth, and it mirrors the skill -# dirs they publish into SKILLS// so a fix is made once at the source and -# flows here. One mount mechanism, not two: the "mounting" the README describes is -# this vendoring, gate-checked by verify-ops.sh. -# -# Manifest: SKILLS/VENDORED.tsv. One row per skill, tab-separated: -# -# The mirror for a row lands at $ROOT/SKILLS//. Lines starting with # and -# blank lines are ignored. -# -# Usage: -# skills-vendor.sh sync (default): mirror each source dir into -# SKILLS// (rsync -a --delete semantics, -# built in a temp dir and swapped in). Prints one -# line per skill: SYNCED / UNCHANGED / SKIP, plus -# a BACKUP line naming where a folder sync did -# not write was moved (see "Ownership" below), -# and a RESTORED line when a folder went back to -# its place (a failed install, or one an -# interrupted run left aside). -# skills-vendor.sh sync same as above, explicit. -# skills-vendor.sh --check read-only drift gate. Prints DRIFT / OK / -# MISSING per skill. Exit 1 if any DRIFT, 2 if any -# MISSING and no DRIFT, 0 clean. Fails loud: a -# missing manifest or tool exits 3. -# -# verify-ops.sh runs `skills-vendor.sh --check` as its skills-mirror check and -# reports FAIL on DRIFT / WARN on MISSING, so an un-synced source edit or an -# uncloned source repo trips the drift gate. deploy.sh clones the public default -# source and runs a sync, so a deployed host starts clean; MISSING (WARN) means -# the clone has not happened (no network at deploy time, or a source of your own -# you have not cloned yet). -# -# The checkout is $OPS_DIR when set (deploy.sh passes the tree it runs from), -# else ~/OPS. rsync is preferred but not required: a host without it (a minimal -# Debian container, Git Bash) syncs through tar with the same excludes and the -# same delete semantics, so a missing package never leaves the mounts unsynced. -# SKILLS_VENDOR_NO_RSYNC=1 forces that path (tests compare the two). Either -# engine builds the new mirror in a temp dir beside the old one and swaps it in -# with a rename, restoring the old mirror if the swap fails: an rsync straight -# into the mirror left it half-updated when rsync failed or was interrupted. -# The renames always target a name that does not exist, which plain mv handles -# the same on GNU and BSD/macOS (mv -T is GNU-only, so every swap failed there). -# A run that is interrupted leaves its SKILLS/.vendor.XXXXXX staging dir behind; -# the next sync cleans it, first moving back a mirror a kill left aside between -# the two renames (RESTORED line). A directory lock refuses overlapping syncs -# before cleanup can mistake a live run's staging for interrupted work. A kill -# that skips EXIT leaves the lock; recovery requires confirming no sync is -# active, then removing the empty lock directory named in the error. -# -# Ownership: sync never deletes a folder it did not write. A manifest row -# claims SKILLS/, but the folder already there can be the Operator's own -# skill (a release that adds a row, as 2026-10-19 added grill-me, tdd and -# diagnosing-bugs, meets every existing copy that kept its own SKILLS/tdd). -# SKILLS/.vendored-state.tsv records a content digest of each mirror sync -# writes, and an existing destination is updated in place only when it is -# provably a mirror: -# 1. its digest matches the recorded one (what sync last wrote), or -# 2. it already equals the source (the sync has nothing to remove). -# Anything else, or any destination holding a .git (sync never writes one), is -# moved to .claude-config/backup/skills-replaced/-/, outside the -# skills index, before the install, and the BACKUP line is printed at once, so -# a later failure still tells the user where the folder went; a failed install -# moves it back if its path is still free, retaining both copies otherwise. -# The digest skips the GUI-local files, which sync keeps in -# place, so GUI authoring in a mirror never reads as foreign content. A -# hand-edited mirror does, and is kept the same way. A folder with no record -# that differs from its source is kept the same way too, even under one of the -# six names that mounted before the record existed: a pre-record mirror that is -# behind its source cannot be told from the Operator's own or hand-edited copy, -# and treating those names as owned overwrote such a copy with no backup. Its -# GUI-local files move with it. - -set -uo pipefail - -ROOT="${OPS_DIR:-$HOME/OPS}" -if [ ! -d "$ROOT" ]; then - echo "skills-vendor: no harness root found ($ROOT)" >&2 - exit 3 -fi -ROOT="$(cd "$ROOT" && pwd -P)" || exit 3 - -PROJECTS="$ROOT/PROJECTS" -SKILLS="$ROOT/SKILLS" -MANIFEST="$SKILLS/VENDORED.tsv" -# A mirror root must be a real directory: rsync follows a destination symlink -# with a trailing slash, and the fallback creates its staging dirs here. -if [ -L "$SKILLS" ] || [ ! -d "$SKILLS" ]; then - echo "skills-vendor: unsafe skills directory: $SKILLS" >&2 - exit 3 -fi -if [ -d "$PROJECTS" ]; then - PROJECTS="$(cd "$PROJECTS" && pwd -P)" || exit 3 -fi - -# GUI dual-track scaffolding is SKILLS-local by convention: the claude.ai Project -# mirror (00_System_Prompt.md, its SETUP.md install guide, and the -# 05_gui_dual_track.md doctrine note) is kept out of shared skill repos, so the -# source repos deliberately lack it. SKILLS is the GUI-authoring home, so exclude -# these from the --delete sync (the mirror keeps them; --delete would destroy the -# only copy) and from the drift check (so they never read as false DRIFT). If a -# source repo ever legitimately ships one of these names, revisit this list. The -# exclusion stays for any mounted skill that gains a GUI mirror, whichever skills -# the manifest mounts at the time. -GUI_LOCAL=('00_System_Prompt.md' '05_gui_dual_track.md' 'SETUP.md') - -LEDGER="$SKILLS/.vendored-state.tsv" -BACKUP_ROOT="$ROOT/.claude-config/backup/skills-replaced" - -[ -f "$MANIFEST" ] || { echo "skills-vendor: manifest missing: $MANIFEST" >&2; exit 3; } - -MODE="${1:-sync}" -case "$MODE" in - sync|--check) ;; - *) echo "usage: skills-vendor.sh [sync|--check]" >&2; exit 3 ;; -esac - -USE_RSYNC=1 -if [ "${SKILLS_VENDOR_NO_RSYNC:-0}" = 1 ] || ! command -v rsync >/dev/null 2>&1; then - USE_RSYNC=0 -fi -if [ "$MODE" = sync ] && [ "$USE_RSYNC" = 0 ]; then - command -v tar >/dev/null 2>&1 || { echo "skills-vendor: neither rsync nor tar found" >&2; exit 3; } -fi -# The ownership digest. Without a hasher sync cannot tell a mirror from a local -# folder, so it stops rather than guess. -HASH_CMD=() -if command -v sha256sum >/dev/null 2>&1; then - HASH_CMD=(sha256sum) -elif command -v shasum >/dev/null 2>&1; then - HASH_CMD=(shasum -a 256) -elif [ "$MODE" = sync ]; then - echo "skills-vendor: neither sha256sum nor shasum found: cannot tell a mirror from a local folder" >&2 - exit 3 -fi - -# Build the exclude args once, in rsync, tar, and diff shapes. -RSYNC_EXCL=(--exclude='.git') -TAR_EXCL=(--exclude='.git') -DIFF_EXCL=(-x '.git') -GUI_FIND=() -for g in "${GUI_LOCAL[@]}"; do - RSYNC_EXCL+=(--exclude="$g") - TAR_EXCL+=(--exclude="$g") - DIFF_EXCL+=(-x "$g") - [ "${#GUI_FIND[@]}" -eq 0 ] || GUI_FIND+=(-o) - GUI_FIND+=(-name "$g") -done - -# Validate the whole manifest before any mount changes. A bad later row must -# not leave an earlier mirror partially synced. Membership declares ownership; -# it does not grant access to SKILLS itself, a symlink target, or a local file. -names=() -sources=() -while IFS=$'\t' read -r name src || [ -n "$name" ]; do - case "$name" in ''|'#'*) continue ;; esac - [ -n "$src" ] || { echo "skills-vendor: malformed manifest row (no source): '$name'" >&2; exit 3; } - if [[ ! "$name" =~ ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ ]]; then - echo "skills-vendor: unsafe manifest name: '$name'" >&2; exit 3 - fi - case "$src" in *..*|/*|.|./*|*/./*|*/.) echo "skills-vendor: unsafe manifest source: '$src'" >&2; exit 3 ;; esac - srcdir="$PROJECTS/$src" - dstdir="$SKILLS/$name" - if [ -L "$dstdir" ] || { [ -e "$dstdir" ] && [ ! -d "$dstdir" ]; }; then - echo "skills-vendor: unsafe mirror destination: $dstdir" >&2; exit 3 - fi - if [ -d "$srcdir" ]; then - srcdir="$(cd "$srcdir" && pwd -P)" || exit 3 - case "$srcdir" in - "$PROJECTS"/*) ;; - *) echo "skills-vendor: source escapes PROJECTS: $src" >&2; exit 3 ;; - esac - fi - names+=("$name") - sources+=("$srcdir") -done < "$MANIFEST" - -# Refuse a source symlink where preserving a GUI-local file needs a directory. -# mkdir -p and cp would otherwise follow it and write outside the staging tree. -gui_parent_dirs() { - local base="$1" rel="${2#./}" component - while [[ "$rel" == */* ]]; do - component="${rel%%/*}" - rel="${rel#*/}" - base="$base/$component" - [ ! -L "$base" ] && mkdir -p "$base" || return 1 - done -} - -# stage_mirror : build the new mirror in a temp dir beside , -# then swap it in only when it differs. Prints "changed" or "same", a tab, -# and the staged digest. Returns non-zero on any failure; a swap collision -# retains the previous mirror for recovery. Copy failures only touch staging. -# rsync: start from a copy of , so rsync's excludes keep its GUI-local -# files, --delete drops stale ones, and its itemized output says whether -# anything changed, exactly as the old in-place sync did. -# tar: the source minus the excludes, plus 's own GUI-local files, and -# a content compare against . -stage_mirror() { - local src="$1" dst="$2" tmp rel rc out content digest marker mirror_state=changed - tmp="$(mktemp -d "$SKILLS/.vendor.XXXXXX")" || return 1 - # The skill this staging dir belongs to, so a later run can put back a - # mirror a kill left in $tmp/previous (clean_stale). - printf '%s\n' "${dst##*/}" > "$tmp/name" || { rm -rf "$tmp"; return 1; } - if [ "$USE_RSYNC" = 1 ]; then - if [ -d "$dst" ]; then - cp -a "$dst" "$tmp/tree" || { rm -rf "$tmp"; return 1; } - else - mkdir "$tmp/tree" || { rm -rf "$tmp"; return 1; } - fi - # --checksum: rsync's default quick check skips a file whose size and mtime - # match, so an edit that kept the size within the same second stayed DRIFT - # (--check compares content) while sync said UNCHANGED. Skill dirs are - # small; comparing content costs nothing. - out="$(rsync -ai --checksum --delete "${RSYNC_EXCL[@]}" "$src"/ "$tmp/tree"/ 2>&1)" - rc=$? - if [ "$rc" -ne 0 ]; then - echo "skills-vendor: rsync failed (rc=$rc)" >&2 - [ -n "$out" ] && echo "$out" >&2 - rm -rf "$tmp"; return 1 - fi - # -i also itemizes time-only updates (".d..t......", ".f..t......"): a - # mirror whose directory mtime moved (a GUI-local file written into it, a - # restore) read as changed or not depending on which second the steps fell - # in, so the sync result flipped between SYNCED and UNCHANGED (seen - # 2026-10-19 as a 2-in-12 test flake). Only those lines are ignored; a mode, - # owner or content change still counts. - content="$(printf '%s\n' "$out" | grep -v -E '^\.[a-zA-Z]\.\.[tT]\.{6}( |$)' | grep -v '^$' || true)" - if [ -d "$dst" ] && [ -z "$content" ]; then - mirror_state=same - fi - else - mkdir "$tmp/tree" || { rm -rf "$tmp"; return 1; } - if ! (cd "$src" && tar "${TAR_EXCL[@]}" -cf - .) | (cd "$tmp/tree" && tar -xf -); then - rm -rf "$tmp"; return 1 - fi - if [ -d "$dst" ]; then - # Save find's status as well as its NUL-delimited results. Process - # substitution hides read errors and newline-delimited names lose data. - # Like rsync's excludes, preserve matching symlinks and whole directories; - # prune them so their children cannot be copied a second time. - (cd "$dst" && find . \( "${GUI_FIND[@]}" \) -prune -print0) > "$tmp/gui-files" || { rm -rf "$tmp"; return 1; } - while IFS= read -r -d '' rel; do - gui_parent_dirs "$tmp/tree" "$rel" && [ ! -L "$tmp/tree/$rel" ] && - cp -a "$dst/$rel" "$tmp/tree/$rel" || { rm -rf "$tmp"; return 1; } - done < "$tmp/gui-files" - fi - if [ -d "$dst" ]; then - diff -rq --no-dereference "$tmp/tree" "$dst" >/dev/null 2>&1 - rc=$? - case "$rc" in - 0) mirror_state=same ;; - 1) ;; - *) rm -rf "$tmp"; return 1 ;; - esac - fi - chmod 755 "$tmp/tree" || { rm -rf "$tmp"; return 1; } - fi - # Record what sync built, never a digest of the live destination afterward: - # an editor can add a file after installation. Claiming that edit in the - # ledger would authorize deleting it as stale on the following sync. - digest="$(tree_digest "$tmp/tree")" || { rm -rf "$tmp"; return 1; } - if [ "$mirror_state" = same ]; then - rm -rf "$tmp" || return 1 - printf 'same\t%s\n' "$digest"; return 0 - fi - # A portable mv can return success by nesting tree/ in a destination that - # appears after the check below. A unique marker proves where our tree - # actually landed before we discard previous/ or authorize it in the ledger. - marker="$(mktemp "$tmp/tree/.vendor-install.XXXXXX")" || { rm -rf "$tmp"; return 1; } - marker="${marker##*/}" - # Keep the prior mirror until installation succeeds. Aim each portable - # rename at a free name, refuse an occupied destination, then use the marker - # above to detect a directory that appeared after the final existence check. - if [ -d "$dst" ]; then - mv "$dst" "$tmp/previous" || { rm -rf "$tmp"; return 1; } - fi - if [ -e "$dst" ] || [ -L "$dst" ] || ! mv "$tmp/tree" "$dst"; then - if [ -d "$tmp/previous" ] && { [ -e "$dst" ] || [ -L "$dst" ] || ! mv "$tmp/previous" "$dst"; }; then - echo "skills-vendor: restore failed; previous mirror retained at $tmp/previous" >&2 - return 1 - fi - rm -rf "$tmp"; return 1 - fi - if [ ! -f "$dst/$marker" ] || [ -L "$dst/$marker" ]; then - echo "skills-vendor: destination changed during install at $dst; nothing recorded; any previous mirror is retained at $tmp/previous" >&2 - return 1 - fi - rm -f "$dst/$marker" || { echo "skills-vendor: could not remove the install marker at $dst/$marker; any previous mirror is retained at $tmp/previous" >&2; return 1; } - rm -rf "$tmp" || return 1 - printf 'changed\t%s\n' "$digest" -} - -# tree_digest : a sha256 over every path, entry type, file content and -# symlink target under , skipping the GUI-local names the way the sync -# does. Paths are NUL-delimited and sorted in the C locale, so the value is the -# same on every machine. Prints "sha256:"; non-zero on any failure. -tree_digest() { - local dir="$1" list rel t sum out - list="$(mktemp "${TMPDIR:-/tmp}/skills-vendor.XXXXXX")" || return 1 - if ! (cd "$dir" && find . \( "${GUI_FIND[@]}" \) -prune -o -print0) > "$list" \ - || ! LC_ALL=C sort -z -o "$list" "$list"; then - rm -f "$list"; return 1 - fi - out="$( - while IFS= read -r -d '' rel; do - if [ -L "$dir/$rel" ]; then - t="$(readlink "$dir/$rel")" || exit 1 - printf 'l\0%s\0%s\0' "$rel" "$t" - elif [ -d "$dir/$rel" ]; then - printf 'd\0%s\0' "$rel" - elif [ -f "$dir/$rel" ]; then - sum="$("${HASH_CMD[@]}" < "$dir/$rel")" || exit 1 - printf 'f\0%s\0%s\0' "$rel" "${sum%% *}" - else - printf 'o\0%s\0' "$rel" - fi - done < "$list" | "${HASH_CMD[@]}" - )" || { rm -f "$list"; return 1; } - rm -f "$list" - printf 'sha256:%s\n' "${out%% *}" -} - -# ledger_get : the recorded digest, or nothing. -ledger_get() { - [ -f "$LEDGER" ] || return 0 - awk -F'\t' -v n="$1" '$1 == n { v = $2 } END { if (v != "") print v }' "$LEDGER" -} - -# ledger_set : record a mirror's digest. Written whole through a -# temp file, so an interrupted run never leaves half a ledger. -ledger_set() { - local tmp - [ "$(ledger_get "$1")" = "$2" ] && return 0 - tmp="$(mktemp "$SKILLS/.vendored-state.XXXXXX")" || return 1 - { - printf '# skills-vendor.sh state: a content digest of each mirror it wrote.\n' - printf '# Generated; do not edit. A folder whose digest is not here is not\n' - printf '# treated as a mirror, so sync moves it aside instead of deleting it.\n' - ( - if [ -f "$LEDGER" ]; then - awk -F'\t' -v n="$1" '!/^#/ && NF >= 2 && $1 != n' "$LEDGER" || exit 1 - fi - printf '%s\t%s\n' "$1" "$2" - ) | LC_ALL=C sort - } > "$tmp" && mv -f "$tmp" "$LEDGER" || { rm -f "$tmp"; return 1; } -} - -# owned_mirror : 0 when is a mirror sync owns (the -# Ownership rules in the header), 1 when it is not, 2 when that cannot be -# decided (the caller stops before changing anything). -owned_mirror() { - local name="$1" src="$2" dst="$3" found recorded current rc - found="$(find "$dst" -name .git -print -quit)" || return 2 - [ -z "$found" ] || return 1 - recorded="$(ledger_get "$name")" || return 2 - current="$(tree_digest "$dst")" || return 2 - [ -n "$recorded" ] && [ "$recorded" = "$current" ] && return 0 - diff -rq --no-dereference "${DIFF_EXCL[@]}" "$src" "$dst" >/dev/null 2>&1 - rc=$? - case "$rc" in - 0) return 0 ;; - 1) ;; - *) return 2 ;; - esac - return 1 -} - -# move_aside : move a folder sync does not own out of the skills -# index. Prints the backup path. -move_aside() { - local name="$1" dst="$2" stamp base path n=1 - stamp="$(date -u +%Y%m%dT%H%M%SZ)" || return 1 - mkdir -p "$BACKUP_ROOT" || return 1 - base="$BACKUP_ROOT/$name-$stamp" - path="$base" - while [ -e "$path" ] || [ -L "$path" ]; do n=$((n + 1)); path="$base-$n"; done - mv -- "$dst" "$path" || return 1 - printf '%s\n' "$path" -} - -# restore_aside : after a failed install, move the folder back -# only when its old path is still free. stage_mirror writes into staging, so -# an existing destination can be independently recreated work; its absence -# earlier does not authorize deleting it. The BACKUP line already names the -# preserved folder; a RESTORED line corrects it when it moves back. -restore_aside() { - local backup="$1" dst="$2" - if [ -e "$dst" ] || [ -L "$dst" ]; then - echo "skills-vendor: could not restore $dst: destination exists; your folder is kept at $backup" >&2 - return 1 - fi - if mv -- "$backup" "$dst"; then - rmdir "$BACKUP_ROOT" 2>/dev/null - echo "skills-vendor: restored $dst" >&2 - printf 'RESTORED %s: the install failed, so the folder is back at %s; the BACKUP path above no longer exists\n' "${dst##*/}" "$dst" - else - echo "skills-vendor: could not restore $dst; your folder is kept at $backup" >&2 - fi -} - -# clean_stale: remove the staging dirs interrupted runs left in SKILLS (they -# are untracked, and the daily backup's git add -A committed them). Only -# directories named exactly like mktemp's .vendor.XXXXXX are touched. One whose -# previous/ is a mirror a kill left aside between the two renames, with its -# skill folder now missing, is moved back first: previous/ can hold the only -# copy of GUI-local files. A previous/ that cannot be placed (an occupied or -# invalid destination, or no name record from an earlier release) goes to the -# backup dir, never to rm: the current destination does not prove that copy -# also contains the old GUI-local work. -clean_stale() { - local d name dest - for d in "$SKILLS"/.vendor.??????; do - case "${d##*/}" in .vendor.[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]) ;; *) continue ;; esac - [ -d "$d" ] && [ ! -L "$d" ] || continue - if [ -d "$d/previous" ] && [ ! -L "$d/previous" ]; then - name=""; [ -f "$d/name" ] && name="$(head -n 1 "$d/name")" - if [[ "$name" =~ ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ ]] && [ ! -e "$SKILLS/$name" ] && [ ! -L "$SKILLS/$name" ]; then - mv "$d/previous" "$SKILLS/$name" || { echo "skills-vendor: could not move $d/previous back to $SKILLS/$name; left it there" >&2; exit 3; } - printf 'RESTORED %s: an interrupted sync had left it in %s; it is back in place\n' "$name" "${d##*/}" - else - dest="$(move_aside "vendor-leftover" "$d/previous")" || { echo "skills-vendor: could not move $d/previous aside; left it there" >&2; exit 3; } - printf 'BACKUP %s: an interrupted sync left a mirror it could not place; kept at %s\n' "${d##*/}" "$dest" - fi - fi - rm -rf "$d" || echo "skills-vendor: could not remove the stale staging dir $d" >&2 - done -} - -drift=0 -missing=0 -if [ "$MODE" = sync ]; then - # Atomic mkdir works on both GNU and BSD hosts. Never guess whether an - # existing lock is stale: an incorrect guess authorizes deleting another - # run's staging, including a mirror it temporarily moved into previous/. - SYNC_LOCK="$SKILLS/.vendor-sync.lock" - if ! mkdir "$SYNC_LOCK" 2>/dev/null; then - echo "skills-vendor: sync lock exists or cannot be created: $SYNC_LOCK; another sync may be active. After confirming no sync is running, remove this empty lock directory and retry" >&2 - exit 3 - fi - trap 'rmdir "$SYNC_LOCK" || echo "skills-vendor: could not remove sync lock: $SYNC_LOCK" >&2' EXIT - trap 'exit 3' HUP INT TERM - clean_stale -fi - -for i in "${!names[@]}"; do - name="${names[$i]}" - srcdir="${sources[$i]}" - src="${srcdir#"$PROJECTS"/}" - dstdir="$SKILLS/$name" - - if [ "$MODE" = "--check" ]; then - if [ ! -d "$srcdir" ]; then - printf 'MISSING %s (source not cloned: %s)\n' "$name" "$src" - missing=1 - elif [ ! -d "$dstdir" ]; then - printf 'DRIFT %s (not vendored yet)\n' "$name" - drift=1 - else - out="$(diff -rq --no-dereference "${DIFF_EXCL[@]}" "$srcdir" "$dstdir" 2>&1)" - rc=$? - if [ "$rc" -gt 1 ]; then - echo "skills-vendor: diff failed for $name (rc=$rc): $out" >&2 - exit 3 - elif [ "$rc" -ne 0 ]; then - printf 'DRIFT %s\n' "$name" - echo "$out" | sed 's/^/ /' - drift=1 - else - printf 'OK %s\n' "$name" - fi - fi - continue - fi - - # sync - if [ ! -d "$srcdir" ]; then - printf 'SKIP %s (source repo not cloned: %s)\n' "$name" "$src" - continue - fi - # A destination sync does not own is moved aside first (Ownership, above). - backup="" - if [ -d "$dstdir" ]; then - owned_mirror "$name" "$srcdir" "$dstdir" - case "$?" in - 0) ;; - 1) - if ! backup="$(move_aside "$name" "$dstdir")"; then - echo "skills-vendor: could not move $dstdir aside; left it as it was" >&2 - exit 3 - fi - # Said now, not after the install: a failure below (or a kill) must - # not leave the folder in the backup with nobody told where it went. - printf 'BACKUP %s: the existing folder was not a mirror sync wrote; kept at %s\n' "$name" "$backup" - ;; - *) - echo "skills-vendor: could not tell whether $dstdir is a mirror sync wrote; left it as it was" >&2 - exit 3 - ;; - esac - fi - engine=tar; [ "$USE_RSYNC" = 1 ] && engine=rsync - if ! res="$(stage_mirror "$srcdir" "$dstdir")"; then - echo "skills-vendor: $engine copy failed for $name; the previous mirror is unchanged" >&2 - [ -n "$backup" ] && restore_aside "$backup" "$dstdir" - exit 3 - fi - case "$res" in - changed$'\t'sha256:*) out=changed ;; - same$'\t'sha256:*) out="" ;; - *) echo "skills-vendor: invalid staging result for $name; nothing recorded" >&2; exit 3 ;; - esac - digest="${res#*$'\t'}" - if ! ledger_set "$name" "$digest"; then - echo "skills-vendor: synced $name but could not record it in $LEDGER" >&2 - exit 3 - fi - if [ -n "$out" ]; then - printf 'SYNCED %s\n' "$name" - else - printf 'UNCHANGED %s\n' "$name" - fi -done - -if [ "$MODE" = "--check" ]; then - [ "$drift" -ne 0 ] && exit 1 - [ "$missing" -ne 0 ] && exit 2 - exit 0 -fi -exit 0 diff --git a/.claude-config/bin/tests/deploy-rc-wiring-test.sh b/.claude-config/bin/tests/deploy-rc-wiring-test.sh index 37559c7..632958d 100755 --- a/.claude-config/bin/tests/deploy-rc-wiring-test.sh +++ b/.claude-config/bin/tests/deploy-rc-wiring-test.sh @@ -673,8 +673,8 @@ printf '%s' "$out" | grep -qF 'Deploy finished with failures: git-identity' || f if printf '%s' "$out" | grep -q 'core-rule\|core.md'; then fail "git-identity alone printed the core-rule note: $out"; fi out="$(deploy_failure_lines " core-rule git-identity")" printf '%s' "$out" | grep -qF 'core-rule means sessions boot without CONTEXT/core.md' || fail "core-rule failure lost its note: $out" -out="$(deploy_failure_lines " skills-mount")" -if printf '%s' "$out" | grep -q 'core.md'; then fail "skills-mount alone printed the core-rule note: $out"; fi +out="$(deploy_failure_lines " memory-init")" +if printf '%s' "$out" | grep -q 'core.md'; then fail "memory-init alone printed the core-rule note: $out"; fi pass "failure summary adds the core-rule note only when core-rule failed" echo "ALL PASS" diff --git a/.claude-config/bin/tests/deploy-skills-mount-test.sh b/.claude-config/bin/tests/deploy-skills-mount-test.sh deleted file mode 100755 index e428744..0000000 --- a/.claude-config/bin/tests/deploy-skills-mount-test.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash -# Exercise deploy's real mount function without network, git writes, or a live -# install. The git stub deliberately leaves partial clones and races publication. -set -euo pipefail -. "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)/../sandbox-guard.sh" && sandbox_guard || exit 97 -DEPLOY="$(cd "$(dirname "$0")/../.." && pwd)/deploy.sh" -WORK="$(mktemp -d "${TMPDIR:-/tmp}/deploy-mount.XXXXXX")" -trap 'rm -rf "$WORK"' EXIT -OPS_ROOT="$WORK/OPS" -SKILLS_SOURCE_DIR="$OPS_ROOT/PROJECTS/Exploitacious/agent-skills" -export SKILLS_SOURCE_URL='https://invalid.example/agent-skills.git' -SKILLS_VENDOR="$WORK/vendor.sh" -LOG="$WORK/log" -export LOG -export CHECK_RC=0 -mkdir -p "$OPS_ROOT/SKILLS" -printf 'sample\tExploitacious/agent-skills/skills/sample\n' > "$OPS_ROOT/SKILLS/VENDORED.tsv" -cat > "$SKILLS_VENDOR" <<'STUB' -#!/usr/bin/env bash -printf '%s %s\n' "$1" "$OPS_DIR" >> "$LOG" -if [[ "$1" == --check ]]; then exit "$CHECK_RC"; fi -STUB -msg_ok() { :; } -msg_warn() { :; } -msg_bad() { :; } -fail() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } -eval "$(awk '/^mount_skills\(\) \{/ {p=1} p {print} p && /^}/ {exit}' "$DEPLOY")" -# BSD/macOS mv has no -T. Every case below runs with an mv that rejects it, -# so a GNU-only publish step fails here instead of on a Mac (2026-10-19). -mv() { - local a - for a in "$@"; do - [[ "$a" == -- ]] && break - [[ "$a" == -*T* ]] && { printf 'mv: illegal option -- T\n' >&2; return 1; } - done - command mv "$@" -} -GIT_MODE=fail -git() { - printf '%s\n' "$*" >> "$LOG" - if [[ "$1" == -C ]]; then - [[ "$GIT_MODE" != incomplete ]] - return - fi - [[ "$1" == clone ]] || fail "unexpected git operation: $*" - local dest="${*: -1}" - mkdir -p "$dest/.git" - printf 'partial\n' > "$dest/partial" - [[ "$GIT_MODE" != fail ]] || return 128 - rm "$dest/partial" - printf 'complete\n' > "$dest/complete" - if [[ "$GIT_MODE" == race ]]; then - mkdir -p "$SKILLS_SOURCE_DIR" - printf 'user data\n' > "$SKILLS_SOURCE_DIR/sentinel" - fi -} -if mount_skills; then fail 'failed clone reported success'; fi -[[ ! -e "$SKILLS_SOURCE_DIR" ]] || fail 'failed clone poisoned the canonical source path' -[[ -z "$(find "$WORK" -name 'agent-skills.clone.*' -print -quit)" ]] || fail 'failed clone leaked a temporary tree' -GIT_MODE=ok -mount_skills || fail 'retry after a failed clone failed' -[[ -f "$SKILLS_SOURCE_DIR/complete" ]] || fail 'completed clone not published' -[[ "$(grep -c '^sync ' "$LOG")" == 1 ]] || fail 'mount did not run sync exactly once' -: > "$LOG" -mount_skills || fail 'redeploy of an existing clone failed' -! grep -q '^clone\|pull' "$LOG" || fail 'redeploy cloned or pulled the existing source' -CHECK_RC=2 -if mount_skills; then fail 'sync skipped a missing mount but deploy reported success'; fi -CHECK_RC=0 -GIT_MODE=incomplete -if mount_skills; then fail 'an incomplete existing clone reported success'; fi -[[ -f "$SKILLS_SOURCE_DIR/complete" ]] || fail 'incomplete-clone check changed the existing source' -rm -rf "$SKILLS_SOURCE_DIR" -GIT_MODE=race -if mount_skills; then fail 'concurrent destination creation reported success'; fi -[[ "$(cat "$SKILLS_SOURCE_DIR/sentinel")" == 'user data' ]] || fail 'publication overwrote a concurrent destination' -[[ ! -e "$SKILLS_SOURCE_DIR/complete" ]] || fail 'publication copied into a concurrent destination' -[[ -z "$(find "$WORK" -name 'agent-skills.clone.*' -print -quit)" ]] || fail 'publication conflict leaked a temporary tree' -printf 'PASS: clone failure, retry, redeploy, incomplete clone and publication collision (BSD-style mv)\n' diff --git a/.claude-config/bin/tests/deploy-windows-test.ps1 b/.claude-config/bin/tests/deploy-windows-test.ps1 index 4bdfe08..222b358 100644 --- a/.claude-config/bin/tests/deploy-windows-test.ps1 +++ b/.claude-config/bin/tests/deploy-windows-test.ps1 @@ -75,10 +75,8 @@ try { Remove-Item Function:\New-Item Write-Host 'PASS: fallback path collision preserves the competing link target' - $skillsBlock = Extract-Block '# --- Mount the shared skills ' '# --- Claude Code plugins:' $OpsRoot = Join-Path $fixture 'ops' New-Item -ItemType Directory -Path (Join-Path $OpsRoot 'SKILLS') -Force | Out-Null - [IO.File]::WriteAllText((Join-Path $OpsRoot 'SKILLS/VENDORED.tsv'), "alpha`tExploitacious/agent-skills/SKILLS/alpha`n") $ConfigDir = Join-Path $OpsRoot '.claude-config' $ClaudeHome = Join-Path $fixture 'claude' New-Item -ItemType Directory -Path $ClaudeHome -Force | Out-Null @@ -94,115 +92,6 @@ try { Assert ($DeployFailed -contains 'link-commands') 'Missing source directory was not recorded' Remove-Item Function:\New-Item Write-Host 'PASS: failed skill links and missing source directories mark deployment failed' - function git { - param($Action, $Quiet, $Url, $Destination) - New-Item -ItemType Directory -Path $Destination -Force | Out-Null - New-Item -ItemType Directory -Path (Join-Path $Destination '.git') -Force | Out-Null - [IO.File]::WriteAllText((Join-Path $Destination 'interrupted'), 'partial clone') - $global:LASTEXITCODE = 128 - } - $DeployFailed = @(); $BashExe = $null - Invoke-Expression $skillsBlock - Assert ($DeployFailed -contains 'skills-mount') 'Clone failure was not recorded' - Assert (-not (Test-Path -LiteralPath $SkillsSrcDir)) 'Failed clone occupied the canonical skill source' - Assert (@(Get-ChildItem -LiteralPath (Split-Path $SkillsSrcDir -Parent) -Filter '.agent-skills.clone-*' -Force).Count -eq 0) 'Failed clone left a temporary directory' - Write-Host 'PASS: failed skills clone marks failure and leaves its canonical path free' - function git { - param($Action, $Quiet, $Url, $Destination) - New-Item -ItemType Directory -Path (Join-Path $Destination '.git') -Force | Out-Null - $global:LASTEXITCODE = 0 - } - $DeployFailed = @() - Invoke-Expression $skillsBlock - Assert (Test-Path -LiteralPath (Join-Path $SkillsSrcDir '.git')) 'Retry did not publish the complete clone' - Write-Host 'PASS: deployment retries and publishes a complete clone' - $SkillsSrcDir = Join-Path $OpsRoot 'PROJECTS/Exploitacious/agent-skills' - New-Item -ItemType Directory -Path (Join-Path $SkillsSrcDir '.git') -Force | Out-Null - $DeployFailed = @() - Invoke-Expression $skillsBlock - Assert ($DeployFailed -contains 'skills-mount') 'Missing Git Bash was not recorded' - Write-Host 'PASS: missing Git Bash marks skills deployment failed' - Remove-Item -LiteralPath $SkillsSrcDir -Recurse -Force - function git { - param($Action, $Quiet, $Url, $Destination) - New-Item -ItemType Directory -Path (Join-Path $Destination '.git') -Force | Out-Null - New-Item -ItemType Directory -Path $SkillsSrcDir -Force | Out-Null - [IO.File]::WriteAllText((Join-Path $SkillsSrcDir 'operator-file'), 'preserve') - $global:LASTEXITCODE = 0 - } - $DeployFailed = @() - Invoke-Expression $skillsBlock - Assert ($DeployFailed -contains 'skills-mount') 'Concurrent clone destination was accepted' - Assert ([IO.File]::ReadAllText((Join-Path $SkillsSrcDir 'operator-file')) -eq 'preserve') 'Concurrent destination was damaged' - Assert (@(Get-ChildItem -LiteralPath $SkillsSrcDir -Force).Count -eq 1) 'Clone was nested into the concurrent destination' - Write-Host 'PASS: clone publication preserves a destination created concurrently' - Remove-Item Function:\git - - $nativeBash = Get-Command bash -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 - if ($nativeBash -and $PSVersionTable.Platform -eq 'Unix') { - $oldRoot = $OpsRoot - $OpsRoot = Join-Path $fixture "OPS O'Neill" - [IO.Directory]::Move($oldRoot, $OpsRoot) - $SkillsSrcDir = Join-Path $OpsRoot 'PROJECTS/Exploitacious/agent-skills' - New-Item -ItemType Directory -Path (Join-Path $SkillsSrcDir '.git') -Force | Out-Null - New-Item -ItemType Directory -Path (Join-Path $OpsRoot '.claude-config/bin') -Force | Out-Null - $sourceSkill = Join-Path $SkillsSrcDir 'SKILLS/alpha/SKILL.md' - New-Item -ItemType Directory -Path (Split-Path $sourceSkill -Parent) -Force | Out-Null - [IO.File]::WriteAllText($sourceSkill, 'skill source') - # .gitattributes checks *.ps1 out with CRLF, and this here-string - # inherits the file's line endings; bash rejects a CRLF script, so a - # fresh clone failed this case. Write the fixture with LF only. - [IO.File]::WriteAllText((Join-Path $OpsRoot '.claude-config/bin/skills-vendor.sh'), (@' -[ "$OPS_DIR" = "$OPS_TEST_EXPECTED_ROOT" ] || exit 22 -source="$OPS_DIR/PROJECTS/Exploitacious/agent-skills/SKILLS/alpha/SKILL.md" -case "$1" in - sync) - [ -f "$source" ] || exit 0 - mkdir -p "$OPS_DIR/SKILLS/alpha" - cp "$source" "$OPS_DIR/SKILLS/alpha/SKILL.md" - printf 'mounted' > "$OPS_DIR/SKILLS/mounted.txt" - printf 'BACKUP alpha: the existing folder was not a mirror sync wrote; kept at %s\n' "$OPS_DIR/.claude-config/backup/skills-replaced/alpha-test" - printf 'SYNCED alpha\n' - ;; - --check) - [ -f "$source" ] && [ -f "$OPS_DIR/SKILLS/alpha/SKILL.md" ] || exit 2 - cmp "$source" "$OPS_DIR/SKILLS/alpha/SKILL.md" || exit 1 - ;; - *) exit 23 ;; -esac -'@ -replace "`r", '')) - $env:OPS_TEST_EXPECTED_ROOT = $OpsRoot - function Invoke-FixtureBash { - param($Mode) - # Git Bash's cygpath is unavailable on Linux; identity conversion - # still exercises the real script's shell quoting and exit status. - $body = 'cygpath() { printf "%s\n" "$2"; }' + "`n" + (@($input) -join "`n") - ($body + "`r`n") | & $nativeBash.Source -s - $global:LASTEXITCODE = $LASTEXITCODE - } - $BashExe = 'Invoke-FixtureBash' - $DeployFailed = @() - $script:warnings = @() - function Write-Warn { param($Msg) $script:warnings += @("$Msg") } - Invoke-Expression $skillsBlock - Assert ($DeployFailed.Count -eq 0) 'Skill sync failed with a spaced or apostrophe path' - Assert ([IO.File]::ReadAllText((Join-Path $OpsRoot 'SKILLS/mounted.txt')) -eq 'mounted') 'Skill sync did not reach the intended root' - Assert ($null -eq $env:OPS_DEPLOY_ROOT) 'Skill sync leaked its temporary root environment' - Write-Host 'PASS: skill sync handles spaces and apostrophes as literal path data' - # A successful sync that moved a folder aside must say where it went. - Assert (@($script:warnings | Where-Object { $_ -match '^\s*BACKUP alpha: .*kept at .*alpha-test$' }).Count -eq 1) "A successful sync hid its BACKUP line: $($script:warnings -join ' | ')" - Assert (@($script:warnings | Where-Object { $_ -match 'SYNCED' }).Count -eq 0) 'A successful sync echoed more than its BACKUP and RESTORED lines' - function Write-Warn { param($Msg) } - Write-Host 'PASS: a successful sync shows its BACKUP line' - Remove-Item -LiteralPath $sourceSkill -Force - $DeployFailed = @() - Invoke-Expression $skillsBlock - Assert ($DeployFailed -contains 'skills-mount') 'Successful sync with a missing source skill was treated as a complete mount' - Write-Host 'PASS: successful sync followed by missing-mount check rc 2 fails deployment' - Remove-Item Function:\Invoke-FixtureBash - Remove-Item Env:\OPS_TEST_EXPECTED_ROOT - } - else { Write-Host 'SKIP: POSIX path quoting execution (requires Unix bash)' } $trustFunction = $ast.Find({ param($node) $node -is [Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Set-TrustAnchor' }, $true) Assert ($null -ne $trustFunction) 'Set-TrustAnchor was not found' @@ -244,7 +133,7 @@ esac # copy with no origin does, so the block never runs git. Run the real block # with the ScheduledTask cmdlets replaced by recorders; the repos are real, # made with the real git, and a git recorder is in scope only for the block. - $taskBlock = Extract-Block '# --- Register daily backup scheduled task ---' '# --- Mount the shared skills' + $taskBlock = Extract-Block '# --- Register daily backup scheduled task ---' '# --- Claude Code plugins:' $bashLine = '$BashExe = Resolve-BashExe' Assert ($taskBlock.Contains($bashLine)) 'The task block no longer resolves bash with Resolve-BashExe' $taskBlock = $taskBlock.Replace($bashLine, '$BashExe = $FixtureBash') @@ -333,12 +222,12 @@ esac function Write-Status { param($Msg, $Color) } function Write-Bad { param($Msg) } function Write-Good { param($Msg) } -$DeployFailed = @('skills-mount') +$DeployFailed = @('trust-anchor') $ConfigDir = '.' '@ + "`n" + $summary) & (Get-Process -Id $PID).Path -NoProfile -NonInteractive -File $summaryProbe *> $null Assert ($LASTEXITCODE -eq 1) 'Failed deployment summary returned success' - $probeText = [IO.File]::ReadAllText($summaryProbe).Replace('$DeployFailed = @(''skills-mount'')', '$DeployFailed = @()') + $probeText = [IO.File]::ReadAllText($summaryProbe).Replace('$DeployFailed = @(''trust-anchor'')', '$DeployFailed = @()') [IO.File]::WriteAllText($summaryProbe, $probeText) & (Get-Process -Id $PID).Path -NoProfile -NonInteractive -File $summaryProbe *> $null Assert ($LASTEXITCODE -eq 0) 'Successful deployment summary returned failure' diff --git a/.claude-config/bin/tests/skills-vendor-test.sh b/.claude-config/bin/tests/skills-vendor-test.sh deleted file mode 100755 index 4116c33..0000000 --- a/.claude-config/bin/tests/skills-vendor-test.sh +++ /dev/null @@ -1,660 +0,0 @@ -#!/usr/bin/env bash -# skills-vendor-test.sh: runnable test suite for .claude-config/bin/skills-vendor.sh. -# -# Builds a throwaway OPS tree (manifest, a source repo under PROJECTS/, and a -# stale mirror) under mktemp and drives the script with OPS_DIR pointing there; -# it never reads or writes the real ~/OPS. Asserts: -# - sync mirrors the source minus .git and the GUI-local files, deletes stale -# mirror files, and keeps the mirror's own GUI-local files -# - the rsync engine and the rsync-free tar engine (SKILLS_VENDOR_NO_RSYNC=1, -# the path a host without rsync takes) produce identical trees -# - a rerun reports UNCHANGED; --check reports OK, MISSING, and DRIFT with -# exit codes 0, 2, and 1 -# - OPS_DIR selects the checkout, so HOME is irrelevant -# - ownership: a destination sync did not write (the Operator's own folder, a -# hand-edited mirror, one holding a .git, and any unrecorded folder that -# differs from its source, even under a name that mounted before the record -# existed) is moved to .claude-config/backup/skills-replaced/ with its -# content intact, then replaced; a mirror sync wrote and one already equal -# to its source update in place with no backup; a failed install moves the -# folder back, in both engines -# - a failed rsync or tar copy leaves an owned mirror exactly as it was (the -# new mirror is built in a temp dir and swapped in) -# - the BACKUP line is printed even when a later step fails, and a RESTORED -# line follows it when a failed install moves the folder back; a recreated -# destination is preserved alongside the backup -# - no mv -T: a PATH mv that rejects -T (as BSD/macOS mv does) still syncs -# - stale SKILLS/.vendor.XXXXXX dirs from an interrupted run are cleaned at -# the start of a sync; a mirror a kill left aside between the two renames -# is moved back first (with its GUI-local files); other names are untouched; -# .gitignore keeps the staging dirs out of the backup -# - every unplaceable previous mirror is backed up, and overlapping syncs -# refuse their directory lock before touching another run's staging -# -# Run: bash ~/OPS/.claude-config/bin/tests/skills-vendor-test.sh -# Exit: 0 = all pass; non-zero on first failure. -set -uo pipefail - -. "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)/../sandbox-guard.sh" && sandbox_guard || exit 97 -SV="$(cd "$(dirname "$0")/.." && pwd)/skills-vendor.sh" -[ -f "$SV" ] || { echo "FAIL: skills-vendor.sh missing at $SV" >&2; exit 1; } - -TDIR="$(mktemp -d "${TMPDIR:-/tmp}/skills-vendor-test.XXXXXX")" -trap 'rm -rf "$TDIR"' EXIT - -fail() { echo "FAIL: $*" >&2; exit 1; } -pass() { echo "PASS: $*"; } - -# make_tree : a fresh OPS fixture with one cloned source (alpha) and one -# uncloned (beta), and a stale mirror of alpha. The mirror is a real earlier -# sync of an older source (so the ownership record knows it), plus GUI-local -# files added to the mirror since; then the source moves on. -make_tree() { - local o="$1" s="$1/PROJECTS/src/skills/alpha" - mkdir -p "$o/SKILLS" "$s/old" "$s/refs/"$'two\nlines' "$s/refs/gui-dir" - printf 'alpha\tsrc/skills/alpha\nbeta\tsrc/skills/beta\n# comment row\n' > "$o/SKILLS/VENDORED.tsv" - printf 'old skill body\n' > "$s/SKILL.md" - printf 'stale\n' > "$s/old/stale.md" - run_sv "$o" sync >/dev/null || fail "fixture: the first sync failed" - rm -rf "$s/old" - mkdir -p "$s/.git" - printf 'new skill body\n' > "$s/SKILL.md" - printf 'ref\n' > "$s/refs/a.md" - printf 'source-side GUI file\n' > "$s/00_System_Prompt.md" - printf 'git internals\n' > "$s/.git/HEAD" - printf 'mirror-side GUI prompt\n' > "$o/SKILLS/alpha/00_System_Prompt.md" - printf 'nested GUI setup\n' > "$o/SKILLS/alpha/refs/"$'two\nlines/SETUP.md' - ln -sf 00_System_Prompt.md "$o/SKILLS/alpha/05_gui_dual_track.md" - mkdir -p "$o/SKILLS/alpha/refs/gui-dir/SETUP.md" - printf 'directory scaffold\n' > "$o/SKILLS/alpha/refs/gui-dir/SETUP.md/private.txt" -} - -# run_sv : the script against , with an unrelated HOME. -run_sv() { local o="$1"; shift; HOME="$TDIR/elsewhere" OPS_DIR="$o" bash "$SV" "$@"; } - -check_mirror() { - local m="$1/SKILLS/alpha" label="$2" - [ "$(cat "$m/SKILL.md")" = "new skill body" ] || fail "$label: SKILL.md not refreshed" - [ -f "$m/refs/a.md" ] || fail "$label: nested source file not copied" - [ -e "$m/old/stale.md" ] && fail "$label: stale mirror file survived the sync" - [ -e "$m/.git" ] && fail "$label: .git was copied into the mirror" - [ "$(cat "$m/00_System_Prompt.md")" = "mirror-side GUI prompt" ] || fail "$label: the mirror's GUI-local file was replaced or deleted" - [ "$(cat "$m/refs/"$'two\nlines/SETUP.md')" = "nested GUI setup" ] || fail "$label: a GUI-local file with a newline in its path was lost" - [ -L "$m/05_gui_dual_track.md" ] && [ "$(readlink "$m/05_gui_dual_track.md")" = 00_System_Prompt.md ] || fail "$label: a GUI-local symlink was lost or followed" - [ "$(cat "$m/refs/gui-dir/SETUP.md/private.txt")" = "directory scaffold" ] || fail "$label: a GUI-local directory was lost" - [ -d "$1/SKILLS/beta" ] && fail "$label: an uncloned source produced a mirror dir" - [ -z "$(find "$1/SKILLS" -maxdepth 1 -name '.vendor*.*' ! -name .vendored-state.tsv -print -quit)" ] \ - || fail "$label: a temp dir was left in SKILLS" - [ ! -e "$1/.claude-config/backup/skills-replaced" ] || fail "$label: a mirror sync wrote was moved aside" - grep -q "^alpha sha256:" "$1/SKILLS/.vendored-state.tsv" || fail "$label: the mirror was not recorded" - return 0 -} - -# --- tar engine (what a host without rsync runs). ----------------------------- -make_tree "$TDIR/tar" -out="$(SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/tar" sync)" || fail "tar sync exited non-zero: $out" -printf '%s\n' "$out" | grep -q '^SYNCED alpha$' || fail "tar sync did not report SYNCED alpha: $out" -printf '%s\n' "$out" | grep -q '^SKIP beta ' || fail "tar sync did not SKIP the uncloned source: $out" -check_mirror "$TDIR/tar" "tar engine" -pass "tar engine mirrors the source, drops stale files and .git, keeps GUI-local files" -out="$(SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/tar" sync)" -printf '%s\n' "$out" | grep -q '^UNCHANGED alpha$' || fail "tar rerun was not UNCHANGED: $out" -pass "tar engine rerun reports UNCHANGED" - -# --- rsync engine, and parity with tar. --------------------------------------- -if command -v rsync >/dev/null 2>&1; then - make_tree "$TDIR/rsync" - out="$(run_sv "$TDIR/rsync" sync)" || fail "rsync sync exited non-zero: $out" - check_mirror "$TDIR/rsync" "rsync engine" - diff -r "$TDIR/rsync/SKILLS" "$TDIR/tar/SKILLS" >/dev/null || { diff -r "$TDIR/rsync/SKILLS" "$TDIR/tar/SKILLS" >&2; fail "rsync and tar engines produced different mirrors"; } - pass "rsync and tar engines produce identical mirrors" -else - echo "SKIP: rsync engine parity (rsync not installed)" -fi - -# --- --check: OK + MISSING exits 2; a source edit is DRIFT, exit 1. ----------- -out="$(run_sv "$TDIR/tar" --check)"; rc=$? -[ "$rc" -eq 2 ] || fail "--check with one uncloned source exited $rc, want 2: $out" -printf '%s\n' "$out" | grep -q '^OK alpha$' || fail "--check did not report OK alpha: $out" -printf '%s\n' "$out" | grep -q '^MISSING beta ' || fail "--check did not report MISSING beta: $out" -pass "--check reports OK and MISSING (exit 2)" -printf 'edited at the source\n' >> "$TDIR/tar/PROJECTS/src/skills/alpha/refs/a.md" -out="$(run_sv "$TDIR/tar" --check)"; rc=$? -[ "$rc" -eq 1 ] || fail "--check after a source edit exited $rc, want 1: $out" -printf '%s\n' "$out" | grep -q '^DRIFT alpha$' || fail "--check did not report DRIFT alpha: $out" -pass "--check reports an un-synced source edit as DRIFT (exit 1)" -mkdir -p "$TDIR/tar/PROJECTS/src/skills/beta"; printf 'b\n' > "$TDIR/tar/PROJECTS/src/skills/beta/SKILL.md" -SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/tar" sync >/dev/null || fail "tar sync after the edit failed" -out="$(run_sv "$TDIR/tar" --check)"; rc=$? -[ "$rc" -eq 0 ] || fail "--check after a full sync exited $rc, want 0: $out" -pass "--check is clean (exit 0) once every source is cloned and synced" - -# --- OPS_DIR is the checkout; without it and without ~/OPS the script stops. -- -out="$(env -u OPS_DIR HOME="$TDIR/elsewhere" bash "$SV" --check 2>&1)"; rc=$? -[ "$rc" -eq 3 ] || fail "no OPS_DIR and no ~/OPS exited $rc, want 3: $out" -pass "without OPS_DIR it reads ~/OPS, and a missing root fails loud (exit 3)" - -# Reject the entire manifest before updating any row, in both engines and both -# modes. A late bad row must leave even the earlier stale mirror untouched. -assert_rejected() { - local o="$1" label="$2" mode engine rc out snapshot="$TDIR/before" - rm -rf "$snapshot" - cp -a "$o" "$snapshot" || fail "$label: snapshot failed" - for engine in 0 1; do - for mode in sync --check; do - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" "$mode" 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "$label ($engine, $mode) exited $rc, want 3: $out" - diff -r --no-dereference "$snapshot" "$o" >/dev/null || fail "$label ($engine, $mode) changed the fixture" - done - done -} - -for bad in '.' '../escape' '/absolute' '.hidden'; do - make_tree "$TDIR/bad-name" - printf '%s\tsrc/skills/alpha\n' "$bad" >> "$TDIR/bad-name/SKILLS/VENDORED.tsv" - assert_rejected "$TDIR/bad-name" "unsafe name $bad" -done -for bad in '.' '../escape' '/absolute'; do - make_tree "$TDIR/bad-source" - printf 'bad\t%s\n' "$bad" >> "$TDIR/bad-source/SKILLS/VENDORED.tsv" - assert_rejected "$TDIR/bad-source" "unsafe source $bad" -done -pass "unsafe names and source traversal fail before any mirror changes" - -make_tree "$TDIR/local-file" -printf 'private local notes\n' > "$TDIR/local-file/SKILLS/local.md" -printf 'local.md\tsrc/skills/alpha\n' >> "$TDIR/local-file/SKILLS/VENDORED.tsv" -assert_rejected "$TDIR/local-file" "local file destination" -make_tree "$TDIR/manifest-file" -printf 'VENDORED.tsv\tsrc/skills/alpha\n' >> "$TDIR/manifest-file/SKILLS/VENDORED.tsv" -assert_rejected "$TDIR/manifest-file" "manifest destination" -pass "manifest cannot replace a local file or itself" - -mkdir "$TDIR/outside" -printf 'outside must survive\n' > "$TDIR/outside/SETUP.md" -cp -a "$TDIR/outside" "$TDIR/outside-before" -make_tree "$TDIR/dest-link" -rm -rf "$TDIR/dest-link/SKILLS/alpha" -ln -s "$TDIR/outside" "$TDIR/dest-link/SKILLS/alpha" -assert_rejected "$TDIR/dest-link" "destination symlink" -make_tree "$TDIR/root-link" -mv "$TDIR/root-link/SKILLS" "$TDIR/root-link/actual-skills" -ln -s actual-skills "$TDIR/root-link/SKILLS" -assert_rejected "$TDIR/root-link" "SKILLS root symlink" -make_tree "$TDIR/source-link" -ln -s "$TDIR/outside" "$TDIR/source-link/PROJECTS/escape" -printf 'bad\tescape\n' >> "$TDIR/source-link/SKILLS/VENDORED.tsv" -assert_rejected "$TDIR/source-link" "source symlink outside PROJECTS" -diff -r "$TDIR/outside-before" "$TDIR/outside" >/dev/null || fail "a symlink check changed outside data" -pass "mirror, SKILLS-root, and escaping source symlinks fail without writes" - -# A source symlink must not redirect the fallback's GUI-local preservation copy -# outside its staging directory. Keep the old mirror if that overlay conflicts. -make_tree "$TDIR/gui-link" -printf 'mirror GUI setup\n' > "$TDIR/gui-link/SKILLS/alpha/refs/SETUP.md" -rm -rf "$TDIR/gui-link/PROJECTS/src/skills/alpha/refs" -ln -s "$TDIR/outside" "$TDIR/gui-link/PROJECTS/src/skills/alpha/refs" -cp -a "$TDIR/gui-link/SKILLS" "$TDIR/gui-link-before" -out="$(SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/gui-link" sync 2>&1)"; rc=$? -[ "$rc" -eq 3 ] || fail "GUI overlay symlink exited $rc, want 3: $out" -diff -r --no-dereference "$TDIR/gui-link-before" "$TDIR/gui-link/SKILLS" >/dev/null || fail "GUI overlay failure changed the prior mirror" -diff -r "$TDIR/outside-before" "$TDIR/outside" >/dev/null || fail "GUI overlay wrote outside SKILLS" -pass "tar GUI preservation refuses a source symlink without changing either tree" - -# Inject actual command failures in isolated PATHs. In particular, a failed -# final rename used to run after rm -rf had already destroyed the old mirror. -REAL_MV="$(command -v mv)" -export REAL_MV -for broken in mv tar find cp chmod diff; do - make_tree "$TDIR/failure-$broken" - cp -a "$TDIR/failure-$broken/SKILLS" "$TDIR/failure-$broken-before" - mkdir "$TDIR/bin-$broken" - if [ "$broken" = mv ]; then - cat > "$TDIR/bin-$broken/$broken" <<'STUB' -#!/usr/bin/env bash -for a in "$@"; do case "$a" in */tree) exit 71 ;; esac; done -exec "$REAL_MV" "$@" -STUB - else - printf '#!/usr/bin/env bash\nexit 2\n' > "$TDIR/bin-$broken/$broken" - fi - chmod +x "$TDIR/bin-$broken/$broken" - out="$(PATH="$TDIR/bin-$broken:$PATH" SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/failure-$broken" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "injected $broken failure exited $rc, want 3: $out" - diff -r --no-dereference "$TDIR/failure-$broken-before" "$TDIR/failure-$broken/SKILLS" >/dev/null || fail "injected $broken failure changed the old mirror or leaked staging data" -done -out="$(PATH="$TDIR/bin-diff:$PATH" run_sv "$TDIR/failure-diff" --check 2>&1)"; rc=$? -[ "$rc" -eq 3 ] || fail "--check swallowed diff error (exit $rc): $out" -pass "tar, find, cp, chmod, diff, and final rename failures retain the old mirror and exit 3" - -make_tree "$TDIR/dangling-link" -ln -s missing "$TDIR/dangling-link/PROJECTS/src/skills/alpha/refs/link" -SKILLS_VENDOR_NO_RSYNC=1 run_sv "$TDIR/dangling-link" sync >/dev/null || fail "dangling source symlink sync failed" -out="$(run_sv "$TDIR/dangling-link" --check)"; rc=$? -[ "$rc" -eq 2 ] || fail "--check should compare the dangling symlink itself (exit $rc): $out" -printf '%s\n' "$out" | grep -q '^OK alpha$' || fail "dangling symlink did not compare cleanly: $out" -pass "drift checks compare symlinks without following their targets" - -# --- Ownership: never delete a folder sync did not write. ---------------------- -# add_local : a manifest row whose destination already holds the -# Operator's own skill folder (no record, not a legacy row). -add_local() { - local o="$1" n="$2" - mkdir -p "$o/PROJECTS/src/skills/$n" "$o/SKILLS/$n/notes" - printf '%s\tsrc/skills/%s\n' "$n" "$n" >> "$o/SKILLS/VENDORED.tsv" - printf 'vendored %s\n' "$n" > "$o/PROJECTS/src/skills/$n/SKILL.md" - printf 'my own %s skill\n' "$n" > "$o/SKILLS/$n/SKILL.md" - printf 'local-only notes\n' > "$o/SKILLS/$n/notes/private.md" - printf 'my GUI prompt\n' > "$o/SKILLS/$n/00_System_Prompt.md" -} -backups() { find "$1/.claude-config/backup/skills-replaced" -mindepth 1 -maxdepth 1 2>/dev/null | wc -l | tr -d ' '; } - -engines=(1) -command -v rsync >/dev/null 2>&1 && engines+=(0) -for engine in "${engines[@]}"; do - o="$TDIR/own-$engine" - make_tree "$o" - add_local "$o" gamma - cp -a "$o/SKILLS/gamma" "$TDIR/gamma-before-$engine" - out="$(run_sv "$o" --check)"; rc=$? - [ "$rc" -eq 1 ] && printf '%s\n' "$out" | grep -q '^DRIFT gamma$' \ - || fail "engine $engine: --check did not report the local folder as DRIFT (exit $rc): $out" - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync)" || fail "engine $engine: sync over a local folder failed: $out" - line="$(printf '%s\n' "$out" | grep '^BACKUP gamma: ')" || fail "engine $engine: no BACKUP line for gamma: $out" - [ "$(printf '%s\n' "$out" | grep -c '^BACKUP')" = 1 ] || fail "engine $engine: a mirror sync wrote was moved aside: $out" - backup="${line##* kept at }" - case "$backup" in */.claude-config/backup/skills-replaced/gamma-*Z) ;; *) fail "engine $engine: backup outside the backup dir: $backup" ;; esac - diff -r --no-dereference "$TDIR/gamma-before-$engine" "$backup" >/dev/null || fail "engine $engine: the backup lost the local folder's content" - [ "$(cat "$o/SKILLS/gamma/SKILL.md")" = "vendored gamma" ] || fail "engine $engine: gamma was not installed" - [ ! -e "$o/SKILLS/gamma/notes" ] && [ ! -e "$o/SKILLS/gamma/00_System_Prompt.md" ] || fail "engine $engine: local content stayed in the mirror" - printf '%s\n' "$out" | grep -q '^SYNCED gamma$' || fail "engine $engine: gamma not SYNCED: $out" - out="$(run_sv "$o" --check)"; rc=$? - [ "$rc" -eq 2 ] && printf '%s\n' "$out" | grep -q '^OK gamma$' || fail "engine $engine: --check after the sync (exit $rc): $out" - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync)" || fail "engine $engine: rerun failed" - printf '%s\n' "$out" | grep -q '^UNCHANGED gamma$' || fail "engine $engine: rerun not UNCHANGED: $out" - printf 'vendored gamma v2\n' > "$o/PROJECTS/src/skills/gamma/SKILL.md" - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync)" || fail "engine $engine: update failed" - printf '%s\n' "$out" | grep -q '^SYNCED gamma$' || fail "engine $engine: update not SYNCED: $out" - printf '%s\n' "$out" | grep -q '^BACKUP' && fail "engine $engine: updating a recorded mirror made a backup: $out" - [ "$(backups "$o")" = 1 ] || fail "engine $engine: expected exactly one backup, found $(backups "$o")" - [ "$(cat "$o/SKILLS/gamma/SKILL.md")" = "vendored gamma v2" ] || fail "engine $engine: recorded mirror not updated" -done -pass "a local folder under a mounted name is kept in the backup intact, then replaced; --check reports it" - -# A hand-edited mirror, and a destination holding a .git, are not mirrors sync -# wrote either. -o="$TDIR/own-edits" -make_tree "$o" -run_sv "$o" sync >/dev/null || fail "hand-edit fixture sync failed" -printf 'my local edit\n' >> "$o/SKILLS/alpha/SKILL.md" -printf 'edited at the source\n' >> "$o/PROJECTS/src/skills/alpha/refs/a.md" -out="$(run_sv "$o" sync)" || fail "sync over a hand-edited mirror failed: $out" -line="$(printf '%s\n' "$out" | grep '^BACKUP alpha: ')" || fail "hand-edited mirror not moved aside: $out" -grep -q 'my local edit' "${line##* kept at }/SKILL.md" || fail "the backup lost the hand edit" -mkdir -p "$o/PROJECTS/src/skills/delta" "$o/SKILLS/delta/.git" -printf 'delta\tsrc/skills/delta\n' >> "$o/SKILLS/VENDORED.tsv" -printf 'delta\n' > "$o/PROJECTS/src/skills/delta/SKILL.md" -printf 'delta\n' > "$o/SKILLS/delta/SKILL.md" -printf 'ref: refs/heads/main\n' > "$o/SKILLS/delta/.git/HEAD" -out="$(run_sv "$o" sync)" || fail "sync over a git checkout failed: $out" -line="$(printf '%s\n' "$out" | grep '^BACKUP delta: ')" || fail "a destination with a .git was not moved aside: $out" -[ -f "${line##* kept at }/.git/HEAD" ] || fail "the backup lost the .git" -pass "a hand-edited mirror and a git checkout are kept in the backup" - -# Folders with no record. One equal to its source is a mirror and updates in -# place. One that differs is kept in the backup, even under a name that mounted -# before the record existed (2026-10-19: those six names counted as owned, so a -# user's own meta-skill-creator was overwritten in place with no backup). -o="$TDIR/own-legacy" -mkdir -p "$o/SKILLS/dynamic-workflows" "$o/SKILLS/epsilon" "$o/SKILLS/meta-skill-creator" \ - "$o/PROJECTS/src/skills/dynamic-workflows" "$o/PROJECTS/src/skills/epsilon" "$o/PROJECTS/src/skills/meta-skill-creator" -printf 'dynamic-workflows\tsrc/skills/dynamic-workflows\nepsilon\tsrc/skills/epsilon\nmeta-skill-creator\tsrc/skills/meta-skill-creator\n' > "$o/SKILLS/VENDORED.tsv" -printf 'current\n' > "$o/PROJECTS/src/skills/dynamic-workflows/SKILL.md" -printf 'older vendored copy\n' > "$o/SKILLS/dynamic-workflows/SKILL.md" -printf 'dropped upstream\n' > "$o/SKILLS/dynamic-workflows/gone.md" -printf 'mirror GUI prompt\n' > "$o/SKILLS/dynamic-workflows/00_System_Prompt.md" -printf 'same\n' > "$o/PROJECTS/src/skills/epsilon/SKILL.md" -printf 'same\n' > "$o/SKILLS/epsilon/SKILL.md" -printf 'vendored meta-skill-creator\n' > "$o/PROJECTS/src/skills/meta-skill-creator/SKILL.md" -printf 'MY OWN HAND-WRITTEN SKILL\n' > "$o/SKILLS/meta-skill-creator/SKILL.md" -printf 'mine\n' > "$o/SKILLS/meta-skill-creator/my-extra.md" -for engine in "${engines[@]}"; do - rm -rf "$TDIR/legacy-$engine"; cp -a "$o" "$TDIR/legacy-$engine" - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$TDIR/legacy-$engine" sync)" || fail "engine $engine: unrecorded sync failed: $out" - m="$TDIR/legacy-$engine/SKILLS" - for n in dynamic-workflows meta-skill-creator; do - line="$(printf '%s\n' "$out" | grep "^BACKUP $n: ")" || fail "engine $engine: unrecorded $n that differs from its source was not moved aside: $out" - diff -r --no-dereference "$o/SKILLS/$n" "${line##* kept at }" >/dev/null || fail "engine $engine: the backup of $n lost content" - printf '%s\n' "$out" | grep -q "^SYNCED $n\$" || fail "engine $engine: $n not SYNCED: $out" - done - [ "$(cat "$m/meta-skill-creator/SKILL.md")" = "vendored meta-skill-creator" ] && [ ! -e "$m/meta-skill-creator/my-extra.md" ] \ - || fail "engine $engine: meta-skill-creator mirror not installed cleanly" - [ "$(cat "$m/dynamic-workflows/SKILL.md")" = current ] && [ ! -e "$m/dynamic-workflows/gone.md" ] \ - || fail "engine $engine: dynamic-workflows mirror not installed" - printf '%s\n' "$out" | grep -q '^UNCHANGED epsilon$' || fail "engine $engine: equal mirror not UNCHANGED: $out" - printf '%s\n' "$out" | grep -q '^BACKUP epsilon' && fail "engine $engine: a mirror equal to its source was moved aside: $out" - for n in dynamic-workflows epsilon meta-skill-creator; do - grep -q "^$n sha256:" "$m/.vendored-state.tsv" || fail "engine $engine: $n was not recorded" - done - [ "$(backups "$TDIR/legacy-$engine")" = 2 ] || fail "engine $engine: expected 2 backups, found $(backups "$TDIR/legacy-$engine")" -done -pass "unrecorded folders: equal to the source updates in place; different is kept in the backup, legacy names included" - -# A failed install moves the local folder back, in both engines. -REAL_RSYNC="$(command -v rsync || true)" -export REAL_RSYNC -mkdir -p "$TDIR/bin-install" -cat > "$TDIR/bin-install/mv" <<'STUB' -#!/usr/bin/env bash -for a in "$@"; do case "$a" in */tree) exit 71 ;; esac; done -exec "$REAL_MV" "$@" -STUB -cat > "$TDIR/bin-install/rsync" <<'STUB' -#!/usr/bin/env bash -src="${*: -2:1}" dst="${*: -1}" -case "$src" in */gamma/) mkdir -p "$dst" && echo partial > "${dst}partial"; exit 23 ;; esac -exec "$REAL_RSYNC" "$@" -STUB -chmod +x "$TDIR/bin-install/mv" "$TDIR/bin-install/rsync" -for engine in "${engines[@]}"; do - o="$TDIR/restore-$engine" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync >/dev/null || fail "engine $engine: restore fixture sync failed" - add_local "$o" gamma - cp -a "$o/SKILLS" "$TDIR/restore-before-$engine" - out="$(PATH="$TDIR/bin-install:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "engine $engine: a failed install exited $rc, want 3: $out" - diff -r --no-dereference "$TDIR/restore-before-$engine" "$o/SKILLS" >/dev/null \ - || fail "engine $engine: the local folder was not restored after a failed install" - [ "$(backups "$o")" = 0 ] || fail "engine $engine: a restored folder also left a backup" - printf '%s\n' "$out" | grep -q 'restored' || fail "engine $engine: the restore was not reported: $out" - # The BACKUP line named a path that is gone now; stdout must say so too. - printf '%s\n' "$out" | grep -A100 '^BACKUP gamma: ' | grep -q "^RESTORED gamma: the install failed, so the folder is back at $o/SKILLS/gamma" \ - || fail "engine $engine: no RESTORED line after the BACKUP line: $out" -done -pass "a failed install moves the local folder back, says so after the BACKUP line, and exits 3" - -# A destination can be recreated after an unowned folder has moved aside. A -# failed install must preserve that new directory as well as the backup, never -# rm -rf a path merely because it was empty earlier in this run. -mkdir -p "$TDIR/bin-recreated" -cat > "$TDIR/bin-recreated/mv" <<'STUB' -#!/usr/bin/env bash -case "${1:-}" in - */tree) - dst="${*: -1}" - case "$dst" in - */gamma) mkdir -p "$dst" && printf 'new independent work\n' > "$dst/new.md"; exit 71 ;; - esac - ;; -esac -exec "$REAL_MV" "$@" -STUB -chmod +x "$TDIR/bin-recreated/mv" -for engine in "${engines[@]}"; do - o="$TDIR/recreated-$engine" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync >/dev/null || fail "engine $engine: recreated fixture sync failed" - add_local "$o" gamma - cp -a "$o/SKILLS/gamma" "$TDIR/recreated-before-$engine" - out="$(PATH="$TDIR/bin-recreated:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "engine $engine: recreated destination exited $rc, want 3: $out" - [ "$(cat "$o/SKILLS/gamma/new.md" 2>/dev/null)" = 'new independent work' ] || fail "engine $engine: restore deleted the independently recreated destination: $out" - line="$(printf '%s\n' "$out" | grep '^BACKUP gamma: ')" || fail "engine $engine: no BACKUP line for conflicting restore: $out" - diff -r --no-dereference "$TDIR/recreated-before-$engine" "${line##* kept at }" >/dev/null || fail "engine $engine: conflicting restore lost the original folder" - printf '%s\n' "$out" | grep -q 'destination exists' || fail "engine $engine: restore did not explain why the backup stayed aside: $out" -done -pass "a failed install preserves an independently recreated destination and the original backup" - -# Plain mv can succeed by nesting tree/ into a directory created after the -# destination check. Never record that independent directory as an owned -# mirror: the next --delete sync would then delete its new.md as stale content. -mkdir -p "$TDIR/bin-nested" -cat > "$TDIR/bin-nested/mv" <<'STUB' -#!/usr/bin/env bash -case "${1:-}" in - */tree) - dst="${*: -1}" - case "$dst" in - */alpha) mkdir -p "$dst" && printf 'new independent work\n' > "$dst/new.md" ;; - esac - ;; -esac -exec "$REAL_MV" "$@" -STUB -chmod +x "$TDIR/bin-nested/mv" -for engine in "${engines[@]}"; do - o="$TDIR/nested-$engine" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync >/dev/null || fail "engine $engine: nested fixture sync failed" - cp "$o/SKILLS/.vendored-state.tsv" "$TDIR/nested-ledger-$engine" - printf 'changed source\n' >> "$o/PROJECTS/src/skills/alpha/SKILL.md" - out="$(PATH="$TDIR/bin-nested:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "engine $engine: nested mv was reported as a successful install: $out" - [ "$(cat "$o/SKILLS/alpha/new.md" 2>/dev/null)" = 'new independent work' ] || fail "engine $engine: nested install lost independent work" - cmp -s "$TDIR/nested-ledger-$engine" "$o/SKILLS/.vendored-state.tsv" || fail "engine $engine: nested install claimed ownership of independent work" - previous="$(find "$o/SKILLS" -mindepth 2 -maxdepth 2 -name previous -type d -print -quit)" - [ "$(cat "$previous/00_System_Prompt.md" 2>/dev/null)" = 'mirror-side GUI prompt' ] || fail "engine $engine: nested install discarded the prior mirror" - printf '%s\n' "$out" | grep -q 'destination changed during install' || fail "engine $engine: nested install was not explained: $out" -done -pass "a successful nested mv is refused without owning independent work or discarding the previous mirror" - -# An editor can write immediately after the rename. The ledger must describe -# the staged copy, not adopt that later edit and permit its deletion next time. -mkdir -p "$TDIR/bin-after-install" -cat > "$TDIR/bin-after-install/mv" <<'STUB' -#!/usr/bin/env bash -case "${1:-}:${*: -1}" in - */tree:*/alpha) - "$REAL_MV" "$@" || exit $? - printf 'concurrent local edit\n' > "${*: -1}/fresh-local.md" - exit 0 - ;; -esac -exec "$REAL_MV" "$@" -STUB -chmod +x "$TDIR/bin-after-install/mv" -for engine in "${engines[@]}"; do - o="$TDIR/after-install-$engine" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync >/dev/null || fail "engine $engine: post-install fixture sync failed" - printf 'changed source\n' >> "$o/PROJECTS/src/skills/alpha/SKILL.md" - out="$(PATH="$TDIR/bin-after-install:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)" || fail "engine $engine: post-install sync failed: $out" - [ "$(cat "$o/SKILLS/alpha/fresh-local.md" 2>/dev/null)" = 'concurrent local edit' ] || fail "engine $engine: concurrent edit fixture did not run" - out="$(SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)" || fail "engine $engine: sync after concurrent edit failed: $out" - line="$(printf '%s\n' "$out" | grep '^BACKUP alpha: ')" || fail "engine $engine: the ledger adopted and deleted the concurrent edit: $out" - [ "$(cat "${line##* kept at }/fresh-local.md" 2>/dev/null)" = 'concurrent local edit' ] || fail "engine $engine: the concurrent edit was not preserved" -done -pass "the ledger records the staged content and preserves edits made immediately after installation" - -# A failed or interrupted rsync must not leave an owned mirror half-updated -# (2026-10-19: rsync --delete ran in place, so a failure left a mirror that -# matched neither the record nor the source, and the next sync moved it aside -# with its GUI-local files). The stub writes into its destination, then fails. -if command -v rsync >/dev/null 2>&1; then - mkdir -p "$TDIR/bin-halfway" - cat > "$TDIR/bin-halfway/rsync" <<'STUB' -#!/usr/bin/env bash -dst="${*: -1}" -mkdir -p "$dst" && echo 'half-written' > "${dst}SKILL.md" && rm -f "${dst}refs/a.md" -exit 23 -STUB - chmod +x "$TDIR/bin-halfway/rsync" - o="$TDIR/halfway" - make_tree "$o" - run_sv "$o" sync >/dev/null || fail "halfway fixture sync failed" - printf 'moved on again\n' >> "$o/PROJECTS/src/skills/alpha/SKILL.md" - cp -a "$o/SKILLS" "$TDIR/halfway-before" - out="$(PATH="$TDIR/bin-halfway:$PATH" run_sv "$o" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "a failing rsync exited $rc, want 3: $out" - diff -r --no-dereference "$TDIR/halfway-before" "$o/SKILLS" >/dev/null \ - || { diff -r --no-dereference "$TDIR/halfway-before" "$o/SKILLS" >&2; fail "a failing rsync changed the owned mirror"; } - [ -z "$(find "$o/SKILLS" -maxdepth 1 -name '.vendor.*' -print -quit)" ] || fail "a failing rsync left a temp dir in SKILLS" - out="$(run_sv "$o" sync)" || fail "the sync after a failed rsync failed: $out" - printf '%s\n' "$out" | grep -q '^BACKUP' && fail "the sync after a failed rsync moved the mirror aside: $out" - printf '%s\n' "$out" | grep -q '^SYNCED alpha$' || fail "the sync after a failed rsync did not update alpha: $out" - [ "$(cat "$o/SKILLS/alpha/00_System_Prompt.md")" = "mirror-side GUI prompt" ] || fail "the GUI-local file left the mirror" - pass "a failing rsync leaves the owned mirror as it was; the next sync updates it in place" -else - echo "SKIP: failing rsync on an owned mirror (rsync not installed)" -fi - -# The BACKUP line is printed as soon as a folder is moved aside, so a later -# failure (here the ledger write: sort fails unless it is the -z sort of the -# digest) still says where the folder went. -mkdir -p "$TDIR/bin-nosort" -REAL_SORT="$(command -v sort)"; export REAL_SORT -cat > "$TDIR/bin-nosort/sort" <<'STUB' -#!/usr/bin/env bash -case " $* " in *" -z "*) exec "$REAL_SORT" "$@" ;; esac -exit 2 -STUB -chmod +x "$TDIR/bin-nosort/sort" -for engine in "${engines[@]}"; do - o="$TDIR/late-fail-$engine" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync >/dev/null || fail "engine $engine: late-failure fixture sync failed" - add_local "$o" gamma - cp -a "$o/SKILLS/gamma" "$TDIR/late-gamma-$engine" - out="$(PATH="$TDIR/bin-nosort:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)"; rc=$? - [ "$rc" -eq 3 ] || fail "engine $engine: a failed ledger write exited $rc, want 3: $out" - printf '%s\n' "$out" | grep -q 'could not record it' || fail "engine $engine: the ledger failure was not reported: $out" - line="$(printf '%s\n' "$out" | grep '^BACKUP gamma: ')" || fail "engine $engine: no BACKUP line after a late failure: $out" - diff -r --no-dereference "$TDIR/late-gamma-$engine" "${line##* kept at }" >/dev/null || fail "engine $engine: the named backup does not hold the folder" -done -pass "the BACKUP line is printed before a later failure" - -# --- No mv -T: BSD and macOS mv reject it, and every swap failed there. -------- -mkdir -p "$TDIR/bin-bsdmv" -cat > "$TDIR/bin-bsdmv/mv" <<'STUB' -#!/usr/bin/env bash -for a in "$@"; do [ "$a" = -T ] && { echo "mv: illegal option -- T" >&2; exit 64; }; done -exec "$REAL_MV" "$@" -STUB -chmod +x "$TDIR/bin-bsdmv/mv" -for engine in "${engines[@]}"; do - o="$TDIR/bsd-$engine" - make_tree "$o" - out="$(PATH="$TDIR/bin-bsdmv:$PATH" SKILLS_VENDOR_NO_RSYNC="$engine" run_sv "$o" sync 2>&1)" || fail "engine $engine: sync with a BSD-style mv failed: $out" - printf '%s\n' "$out" | grep -q '^SYNCED alpha$' || fail "engine $engine: alpha not SYNCED with a BSD-style mv: $out" - check_mirror "$o" "engine $engine, BSD-style mv" -done -pass "sync never passes mv -T: a mv that rejects it (BSD, macOS) still swaps mirrors in" - -# --- Stale staging dirs from an interrupted run are cleaned. ------------------- -o="$TDIR/stale" -make_tree "$o" -run_sv "$o" sync >/dev/null || fail "stale fixture sync failed" -printf 'gui setup\n' > "$o/SKILLS/alpha/SETUP.md" -mkdir -p "$o/SKILLS/.vendor.Ab12Cd/tree" "$o/SKILLS/.vendor.keep-me" "$o/SKILLS/.vendor.Zz9" -printf 'half copy\n' > "$o/SKILLS/.vendor.Ab12Cd/tree/SKILL.md" -# The state a kill between the two renames leaves: the mirror in previous/, -# the new tree beside it, and SKILLS/alpha missing. -mkdir -p "$o/SKILLS/.vendor.Qw34Er"; printf 'alpha\n' > "$o/SKILLS/.vendor.Qw34Er/name" -mv "$o/SKILLS/alpha" "$o/SKILLS/.vendor.Qw34Er/previous"; mkdir "$o/SKILLS/.vendor.Qw34Er/tree" -# A leftover from an earlier release, with no record of its skill. -mkdir -p "$o/SKILLS/.vendor.Ty56Ui/previous"; printf 'orphan\n' > "$o/SKILLS/.vendor.Ty56Ui/previous/SKILL.md" -out="$(run_sv "$o" sync 2>&1)" || fail "sync over stale staging dirs failed: $out" -printf '%s\n' "$out" | grep -q '^RESTORED alpha: an interrupted sync had left it in .vendor.Qw34Er' || fail "the mirror a kill left aside was not restored: $out" -[ "$(cat "$o/SKILLS/alpha/SETUP.md" 2>/dev/null)" = "gui setup" ] || fail "the restored mirror lost its GUI-local file" -line="$(printf '%s\n' "$out" | grep '^BACKUP .vendor.Ty56Ui: ')" || fail "an unplaceable leftover was not kept in the backup: $out" -[ "$(cat "${line##* kept at }/SKILL.md")" = orphan ] || fail "the leftover's backup lost its content" -[ -z "$(find "$o/SKILLS" -maxdepth 1 -name '.vendor.??????' -print -quit)" ] || fail "a stale staging dir survived: $(ls -a "$o/SKILLS")" -[ -d "$o/SKILLS/.vendor.keep-me" ] && [ -d "$o/SKILLS/.vendor.Zz9" ] || fail "a dir not named like a staging dir was removed" -printf '%s\n' "$out" | grep -q '^UNCHANGED alpha$' || fail "the restored mirror was not recognized as owned: $out" - -# An interrupted swap can retain previous/ because the destination was -# independently recreated, or because a restore collided. That old copy may -# hold the only GUI-local files. A valid name is no proof it is redundant. -for name in alpha '../unsafe'; do - o="$TDIR/stale-collision-${name##*/}" - make_tree "$o" - run_sv "$o" sync >/dev/null || fail "stale collision fixture sync failed" - mkdir -p "$o/SKILLS/.vendor.Cc12Dd/previous" - printf '%s\n' "$name" > "$o/SKILLS/.vendor.Cc12Dd/name" - printf 'only copy of GUI setup\n' > "$o/SKILLS/.vendor.Cc12Dd/previous/SETUP.md" - out="$(run_sv "$o" sync 2>&1)" || fail "stale collision cleanup failed: $out" - line="$(printf '%s\n' "$out" | grep '^BACKUP .vendor.Cc12Dd: ')" || fail "unplaceable previous mirror was removed instead of kept: $out" - [ "$(cat "${line##* kept at }/SETUP.md" 2>/dev/null)" = 'only copy of GUI setup' ] || fail "stale cleanup lost the only GUI-local copy" - [ -d "$o/SKILLS/alpha" ] || fail "stale cleanup replaced the current mirror" -done -pass "stale previous mirrors with an occupied or unsafe destination are kept in the backup" - -# Pause a real sync after it moves the old mirror into staging. Another sync -# must fail before clean_stale can remove or restore the first run's live work. -mkdir -p "$TDIR/bin-overlap" -cat > "$TDIR/bin-overlap/mv" <<'STUB' -#!/usr/bin/env bash -case "${1:-}:${2:-}" in - "$OPS_DIR/SKILLS/alpha":*/previous) - "$REAL_MV" "$@" || exit $? - : > "$OPS_DIR/paused" - for ((n=0; n<200; n++)); do - [ -f "$OPS_DIR/release" ] && exit 0 - sleep 0.05 - done - exit 71 - ;; -esac -exec "$REAL_MV" "$@" -STUB -chmod +x "$TDIR/bin-overlap/mv" -o="$TDIR/overlap" -make_tree "$o" -PATH="$TDIR/bin-overlap:$PATH" SKILLS_VENDOR_NO_RSYNC=1 run_sv "$o" sync > "$o/first.log" 2>&1 & -first_pid=$! -for ((n=0; n<100; n++)); do - [ -f "$o/paused" ] && break - sleep 0.05 -done -if [ ! -f "$o/paused" ]; then - : > "$o/release"; wait "$first_pid" - fail "the overlap fixture did not reach the paused rename" -fi -previous="$(find "$o/SKILLS" -mindepth 2 -maxdepth 2 -name previous -type d -print -quit)" -out="$(SKILLS_VENDOR_NO_RSYNC=1 run_sv "$o" sync 2>&1)"; rc=$? -preserved=0 -[ "$(cat "$previous/00_System_Prompt.md" 2>/dev/null)" = 'mirror-side GUI prompt' ] && preserved=1 -: > "$o/release" -wait "$first_pid"; first_rc=$? -[ "$rc" -eq 3 ] || fail "overlapping sync exited $rc, want 3: $out" -printf '%s\n' "$out" | grep -q 'sync lock' || fail "overlapping sync did not report its lock: $out" -[ "$preserved" -eq 1 ] || fail "overlapping sync touched the active staging directory" -[ "$first_rc" -eq 0 ] || fail "the first sync failed after refusing an overlap: $(cat "$o/first.log")" -[ ! -e "$o/SKILLS/.vendor-sync.lock" ] || fail "a completed sync left its lock" -check_mirror "$o" 'overlapping sync' -# A lock left by SIGKILL is ambiguous. Refuse it and explain manual recovery, -# without removing a potentially active lock or touching any staging. -mkdir "$o/SKILLS/.vendor-sync.lock" "$o/SKILLS/.vendor.Lock12" -printf 'keep active staging\n' > "$o/SKILLS/.vendor.Lock12/marker" -out="$(run_sv "$o" sync 2>&1)"; rc=$? -[ "$rc" -eq 3 ] && printf '%s\n' "$out" | grep -q 'confirming no sync is running' || fail "an existing lock was not refused with recovery instructions: $out" -[ "$(cat "$o/SKILLS/.vendor.Lock12/marker" 2>/dev/null)" = 'keep active staging' ] || fail "a refused lock still cleaned staging" -[ -d "$o/SKILLS/.vendor-sync.lock" ] || fail "a refused lock was removed" -pass "overlapping syncs are refused before cleanup; ambiguous locks require explicit recovery" - -# --- A time-only difference is not a change (2026-10-19 flake: rsync -i also -# itemizes ".d..t......", so the result flipped with the clock). A mode change -# still syncs. Both engines. -for eng in "" 1; do - o="$TDIR/timeonly-${eng:-rsync}" - make_tree "$o" - SKILLS_VENDOR_NO_RSYNC="$eng" run_sv "$o" sync >/dev/null || fail "time-only fixture sync failed" - touch -d '2001-01-01 00:00:00' "$o/SKILLS/alpha" "$o/SKILLS/alpha/refs" - out="$(SKILLS_VENDOR_NO_RSYNC="$eng" run_sv "$o" sync 2>&1)" || fail "time-only resync failed: $out" - printf '%s\n' "$out" | grep -q '^UNCHANGED alpha$' || fail "engine ${eng:-rsync}: a time-only difference read as a change: $out" - chmod +x "$o/PROJECTS/src/skills/alpha/refs/a.md" - out="$(SKILLS_VENDOR_NO_RSYNC="$eng" run_sv "$o" sync 2>&1)" || fail "mode resync failed: $out" - if [ -z "$eng" ]; then - printf '%s\n' "$out" | grep -q '^SYNCED alpha$' || fail "rsync engine: a mode change upstream was not synced: $out" - [ -x "$o/SKILLS/alpha/refs/a.md" ] || fail "rsync engine: the mirror did not take the upstream mode" - fi -done -pass "a time-only difference is not a change; a mode change upstream still syncs (rsync)" - -g="$TDIR/ignore-check"; git init -q "$g" && cp "$(cd "$(dirname "$SV")/../.." && pwd)/.gitignore" "$g/.gitignore" -mkdir -p "$g/SKILLS/.vendor.Ab12Cd"; : > "$g/SKILLS/.vendor.Ab12Cd/x" -git -C "$g" check-ignore -q SKILLS/.vendor.Ab12Cd/x || fail ".gitignore does not keep SKILLS/.vendor.*/ out of the backup" -pass "stale staging dirs are cleaned (a mirror a kill left aside comes back first); .gitignore keeps them out of git" - -echo "ALL PASS" diff --git a/.claude-config/bin/verify-ops-selftest.sh b/.claude-config/bin/verify-ops-selftest.sh index da78de2..6c1fca2 100755 --- a/.claude-config/bin/verify-ops-selftest.sh +++ b/.claude-config/bin/verify-ops-selftest.sh @@ -384,31 +384,15 @@ mkdir -p "$OPS/WORKFORCE" run check_retired_context chk "about-me.md and WORKFORCE/ left behind -> WARN naming both" "$([ "$WARNS" = 1 ] && printf '%s' "$OUT" | grep -q 'about-me.md' && printf '%s' "$OUT" | grep -q 'WORKFORCE/'; echo $?)" -# 12. Line-ref lint (4) skips mounted skills: a line number in a mirror listed -# in VENDORED.tsv is not fixable here; the same text in a local skill WARNs. +# 12. Line-ref lint (4): the shipped skills pass; a line number in a skill WARNs. new_case linerefs -mkdir -p "$OPS/SKILLS/mountedx" "$OPS/SKILLS/localx" -printf 'a finding at line 702 was wrong\n' > "$OPS/SKILLS/mountedx/SKILL.md" -printf 'mountedx\tsrc/skills/mountedx\n' >> "$OPS/SKILLS/VENDORED.tsv" +mkdir -p "$OPS/SKILLS/localx" run check_linerefs -chk "line ref in a mounted skill -> OK" "$([ "$WARNS" = 0 ] && [ "$OKS" = 1 ]; echo $?)" +chk "shipped skills, no line refs -> OK" "$([ "$WARNS" = 0 ] && [ "$OKS" = 1 ]; echo $?)" printf 'a finding at line 702 was wrong\n' > "$OPS/SKILLS/localx/SKILL.md" run check_linerefs chk "line ref in a local skill -> WARN" "$([ "$WARNS" = 1 ] && printf '%s' "$OUT" | grep -q 'localx'; echo $?)" -# A gate cannot return green when its mirror verifier cannot run or encounters -# an unsafe manifest or filesystem error. MISSING sources retain their WARN. -new_case vendored-error -mkdir -p "$OPS/.claude-config/bin" -printf '#!/usr/bin/env bash\necho "skills-vendor: unsafe mirror destination" >&2\nexit 3\n' \ - > "$OPS/.claude-config/bin/skills-vendor.sh" -chmod +x "$OPS/.claude-config/bin/skills-vendor.sh" -run check_skills_vendored -chk "mirror verifier error -> FAIL" "$([ "$FAILS" = 1 ]; echo $?)" -chmod -x "$OPS/.claude-config/bin/skills-vendor.sh" -run check_skills_vendored -chk "mirror verifier not executable -> FAIL" "$([ "$FAILS" = 1 ]; echo $?)" - # 24. Sandbox guards: the shipped suites pass; a fixture suite that names a # destructive tool without the guard FAILs, and missing tooling FAILs. new_case sandbox @@ -597,7 +581,7 @@ out += "b" * (size - len(out.encode())) open(path, "w").write(out) PY } -size_case() { new_case "$1"; rm -rf "${OPS:?}/SKILLS"; mkdir -p "$OPS/SKILLS"; : > "$OPS/SKILLS/VENDORED.tsv"; } +size_case() { new_case "$1"; rm -rf "${OPS:?}/SKILLS"; mkdir -p "$OPS/SKILLS"; } new_case size-shipped run check_skill_size chk "shipped skills within 16 KB and 1,500 characters a line -> OK" "$([ "$FAILS" = 0 ] && [ "$WARNS" = 0 ] && [ "$OKS" = 1 ]; echo $?)" @@ -619,11 +603,10 @@ run check_skill_size chk "a 1,501-character line -> WARN naming the line and its length" \ "$([ "$FAILS" = 0 ] && [ "$WARNS" = 1 ] && printf '%s' "$OUT" | grep -qE 'wide \(line [0-9]+ is 1501 characters\)'; echo $?)" size_case size-skipped -mk_skill mountedx 40000; printf 'mountedx\tsrc/skills/mountedx\n' > "$OPS/SKILLS/VENDORED.tsv" mk_skill synced 40000 mk_skill linked 40000; mv "$OPS/SKILLS/linked" "$HOME/linked-target"; ln -s "$HOME/linked-target" "$OPS/SKILLS/linked" run check_skill_size -chk "mounted, synced and symlinked skills are skipped -> OK" "$([ "$FAILS" = 0 ] && [ "$WARNS" = 0 ]; echo $?)" +chk "synced and symlinked skills are skipped -> OK" "$([ "$FAILS" = 0 ] && [ "$WARNS" = 0 ]; echo $?)" rm -rf "${OPS:?}/SKILLS" run check_skill_size chk "no SKILLS dir -> FAIL, not a pass" "$([ "$FAILS" = 1 ] && printf '%s' "$OUT" | grep -q 'could not run'; echo $?)" diff --git a/.claude-config/bin/verify-ops.sh b/.claude-config/bin/verify-ops.sh index c6941a4..35e9a71 100755 --- a/.claude-config/bin/verify-ops.sh +++ b/.claude-config/bin/verify-ops.sh @@ -91,15 +91,9 @@ check_changelog() { } # 4. Line-ref lint: core docs must not cite code by line number (drift class). -# Mounted skills (SKILLS/VENDORED.tsv) are skipped: they are mirrors edited at -# their source repo, so a hit there is not fixable here, and deploy syncs them -# onto every fresh install. check_linerefs() { - local hits f name mounted="" skills=() - mounted=" $(awk -F'\t' '$1 !~ /^#/ && NF >= 2 {printf "%s ", $1}' "$OPS/SKILLS/VENDORED.tsv" 2>/dev/null)" + local hits f skills=() while IFS= read -r f; do - name="$(basename "$(dirname "$f")")" - case "$mounted" in *" $name "*) continue ;; esac skills+=("$f") done < <(_ops_own_skill_mds) hits="$(grep -rnE '(line ~?[0-9]{2,}|:[0-9]{3,}\))' \ @@ -266,8 +260,7 @@ check_skills_index() { # The SKILL.md files this checkout holds itself, one per line: SKILLS/ # entries that are real directories. A symlinked entry is a machine-local link -# to a skill another repo owns, so it is linted there. Mounted skills -# (SKILLS/VENDORED.tsv) are listed; a check that must skip them does so. +# to a skill another repo owns, so it is linted there. _ops_own_skill_mds() { local d for d in "$OPS"/SKILLS/*/; do @@ -282,21 +275,16 @@ _ops_own_skill_mds() { # past 1,500 characters is a wall the reader skims. Both limits are inclusive. # WARN, never FAIL: trimming a skill is an editing task (split it, or move detail # into a reference file beside it), and a skill the Operator wrote is theirs to -# trim. Skipped: mounted skills (SKILLS/VENDORED.tsv, edited at their source -# repo), SKILLS/synced (Claude Code's claude.ai sync), and a symlinked entry (a -# skill another repo owns). FAIL only when the lint itself cannot run. +# trim. Skipped: SKILLS/synced (Claude Code's claude.ai sync) and a symlinked +# entry (a skill another repo owns). FAIL only when the lint itself cannot run. check_skill_size() { - local py out rc name - local -a mounted=() + local py out rc py="$(hook_python 2>/dev/null)" || { warn "no Python 3: cannot measure skill sizes"; return; } - while IFS= read -r name; do - [ -n "$name" ] && mounted+=("$name") - done < <(awk -F'\t' '$1 !~ /^#/ && NF >= 2 {print $1}' "$OPS/SKILLS/VENDORED.tsv" 2>/dev/null) - out="$("$py" -I - "$OPS/SKILLS" ${mounted[@]+"${mounted[@]}"} 2>&1 <<'PY' + out="$("$py" -I - "$OPS/SKILLS" 2>&1 <<'PY' import os import sys -root, skip = sys.argv[1], set(sys.argv[2:]) | {"synced"} +root, skip = sys.argv[1], {"synced"} LIMIT_BYTES, LIMIT_LINE = 16384, 1500 try: names = sorted(os.listdir(root)) @@ -823,22 +811,8 @@ check_retired_context() { || warn "retired files still present:$left (move their content per DEPLOYMENT.md, \"Migrating to the core boot\", then delete them)" } -# 22. Skills mirror in sync. SKILLS/ for a vendored row is a mirror of a -# source skill repo under PROJECTS/; skills-vendor.sh --check is the drift gate -# (rc 0 clean, 1 DRIFT = source edit not vendored, 2 MISSING = source repo not -# cloned). DRIFT FAILs; MISSING WARNs (a public template ships zero project repos, -# so the source not being cloned is the normal fresh-fork state). -check_skills_vendored() { - local sv="$OPS/.claude-config/bin/skills-vendor.sh" out rc - [ -x "$sv" ] || { fail "skills-vendor.sh missing/not executable: cannot verify mounted skills"; return; } - out="$(OPS_DIR="$OPS" "$sv" --check 2>&1)"; rc=$? - case "$rc" in - 0) ok "skills mirror in sync with source repos" ;; - 1) fail "skills mirror DRIFT (source edit not vendored; run skills-vendor.sh sync):"$'\n'"$(printf '%s' "$out" | grep '^DRIFT' | head -10)" ;; - 2) warn "skills mirror source repo(s) not cloned (run skills-vendor.sh sync after cloning them):"$'\n'"$(printf '%s' "$out" | grep '^MISSING' | head -10)" ;; - *) fail "skills-vendor.sh --check errored (rc=$rc):"$'\n'"$(printf '%s' "$out" | head -5)" ;; - esac -} +# 22. Retired 2026-11-17 with the skill mounts (it checked the mirrored skills +# against their source clone). The number stays free: docs cite checks 23-25. # 23. Identity exclusion. The files BOOTSTRAP fills with the Operator's identity, # rulings, people, and systems must never be overwritten by a template refresh, @@ -873,12 +847,11 @@ check_identity_exclusion() { # pre-compact.sh prunes snapshots by retention and runs branch-gc --apply # memory-init moves memory files into .claude-memory, removes old dirs # deploy.sh runs memory-init; replaces links, rc lines and units -# skills-vendor.sh mirrors skill repos into SKILLS/ (rsync --delete) # Not listed, by the same rule: session-briefing.sh (reads only), # daily-sync.sh (commits and pulls its own checkout; its gc stage is branch-gc, # reached only through a stub in the suites that cover it), and tools that # replace only their own output or state file. -OPS_DESTRUCTIVE_TOOLS=(branch-gc pre-compact.sh memory-init deploy.sh skills-vendor.sh) +OPS_DESTRUCTIVE_TOOLS=(branch-gc pre-compact.sh memory-init deploy.sh) # Suites that must carry the guard although the name check cannot see why. The three # T3 suites: t3-api.sh and compact-cycle.sh delete nothing, but they send messages into # and settle threads on a real T3 server, and the box that runs a suite usually runs one @@ -960,7 +933,6 @@ main() { check_anxiety_vocab check_identity_canary check_retired_context - check_skills_vendored check_identity_exclusion check_sandbox_guards check_memory_links diff --git a/.claude-config/deploy.ps1 b/.claude-config/deploy.ps1 index a129a96..99840be 100644 --- a/.claude-config/deploy.ps1 +++ b/.claude-config/deploy.ps1 @@ -18,10 +18,8 @@ 6. Emit the always-on ultracode shim to the profile.local.ps1 seam 7. Register the daily backup scheduled task (dynamic bash + WorkingDirectory), on every copy (one with no origin remote commits locally) - 8. Mount the shared skills: clone the public skill source under - PROJECTS/ when absent, then run bin/skills-vendor.sh sync in Git Bash - 9. Check for the caveman + ponytail Claude Code plugins (report and offer, never remove) - 10. Pin CLAUDE_CODE_GIT_BASH_PATH + run the security-guard self-test + 8. Check for the caveman + ponytail Claude Code plugins (report and offer, never remove) + 9. Pin CLAUDE_CODE_GIT_BASH_PATH + run the security-guard self-test -NoSystem skips the scheduled task (a system-wide registration), for test installs; deploy.sh's --no-system is the Linux counterpart. @@ -526,92 +524,6 @@ else { } } -# --- Mount the shared skills (clone the public source once, then sync) --- -# Same contract as deploy.sh: clone Exploitacious/agent-skills over HTTPS only -# when absent (never pull an existing clone on a re-deploy), then mirror -# SKILLS/VENDORED.tsv with skills-vendor.sh in Git Bash (it falls back to tar -# where rsync is missing, as in a stock Git Bash). -Write-Host "" -Write-Status "Mounting shared skills..." "Yellow" -$SkillsSrcUrl = "https://github.com/Exploitacious/agent-skills.git" -$SkillsSrcDir = Join-Path $OpsRoot "PROJECTS\Exploitacious\agent-skills" -$Vendored = Join-Path $OpsRoot "SKILLS\VENDORED.tsv" -if (-not ((Test-Path $Vendored) -and (Select-String -Path $Vendored -Pattern '^[^#\s]\S*\s+Exploitacious/agent-skills/' -Quiet))) { - Write-Good "No mounted skills from Exploitacious/agent-skills in SKILLS\VENDORED.tsv" -} -else { - $cloned = Test-Path (Join-Path $SkillsSrcDir ".git") - if (-not $cloned -and (Test-Path $SkillsSrcDir)) { - Write-Bad "$SkillsSrcDir exists but is not a git clone -- move it aside, then re-run."; $DeployFailed += 'skills-mount' - } - elseif (-not $cloned) { - # Publish only a complete clone. Interrupted clones must not occupy the - # canonical source path and prevent a later deploy from retrying. - $cloneParent = Split-Path $SkillsSrcDir -Parent - $cloneTemp = Join-Path $cloneParent ('.agent-skills.clone-' + [guid]::NewGuid()) - $prevEap = $ErrorActionPreference - try { - New-Item -ItemType Directory -Path $cloneParent -Force | Out-Null - $ErrorActionPreference = "Continue" - & git clone --quiet $SkillsSrcUrl $cloneTemp 2>&1 | Out-Null - $cloneRc = $LASTEXITCODE - $ErrorActionPreference = $prevEap - if ($cloneRc -ne 0 -or -not (Test-Path (Join-Path $cloneTemp ".git"))) { throw "git clone failed (rc=$cloneRc)" } - # Directory.Move refuses an existing destination instead of nesting - # into or replacing a source another process created meanwhile. - [IO.Directory]::Move($cloneTemp, $SkillsSrcDir) - $cloned = $true - Write-Good "Cloned $SkillsSrcUrl -> $SkillsSrcDir" - } - catch { Write-Bad "Could not clone ${SkillsSrcUrl}: $_. Mounted skills are missing; re-run to retry."; $DeployFailed += 'skills-mount' } - finally { - $ErrorActionPreference = $prevEap - if (Test-Path -LiteralPath $cloneTemp) { Remove-Item -LiteralPath $cloneTemp -Recurse -Force } - } - } - else { Write-Good "Skill source already cloned: $SkillsSrcDir (not pulled)" } - if ($cloned) { - if ($BashExe) { - # Pass the root as data, including spaces and apostrophes. Piping a - # constant script also avoids Windows PowerShell native argv quoting. - $prevRoot = $env:OPS_DEPLOY_ROOT - $prevEap = $ErrorActionPreference - try { - $env:OPS_DEPLOY_ROOT = $OpsRoot - $ErrorActionPreference = "Continue" - $mountScript = @' -opsUnix=$(cygpath -u "$OPS_DEPLOY_ROOT") || exit -OPS_DIR="$opsUnix" bash "$opsUnix/.claude-config/bin/skills-vendor.sh" sync || exit -# sync skips absent sources; verify every required mount before reporting success. -OPS_DIR="$opsUnix" bash "$opsUnix/.claude-config/bin/skills-vendor.sh" --check -exit $? -'@ - # Windows native pipelines append CRLF. Supply LF script lines - # and exit before that appended newline can become shell input. - $mountScript = ($mountScript -replace "`r", '') + "`n" - $svOut = $mountScript | & $BashExe -ls 2>&1 - $svRc = $LASTEXITCODE - } - catch { $svOut = @($_); $svRc = 1 } - finally { - $ErrorActionPreference = $prevEap - if ($null -eq $prevRoot) { Remove-Item Env:\OPS_DEPLOY_ROOT -ErrorAction SilentlyContinue } - else { $env:OPS_DEPLOY_ROOT = $prevRoot } - } - if ($svRc -eq 0) { - Write-Good "Mounted skills synced into SKILLS\" - # The output is captured, and printed whole only on failure. A - # successful sync can still have moved the Operator's own folder - # aside (BACKUP) or put one back (RESTORED); show those lines, or - # the folder leaves SKILLS\ with no notice. - $svOut | Where-Object { "$_" -match '^(BACKUP|RESTORED) ' } | ForEach-Object { Write-Warn " $_" } - } - else { Write-Bad "skills-vendor.sh sync or completeness check failed:"; $svOut | ForEach-Object { Write-Warn " $_" }; $DeployFailed += 'skills-mount' } - } - else { Write-Bad "Git Bash not found -- mounted skills not synced (install Git for Windows, then re-run deploy.ps1)."; $DeployFailed += 'skills-mount' } - } -} - # --- Claude Code plugins: caveman + ponytail check --- Write-Host "" Write-Status "Checking for the caveman + ponytail Claude Code plugins..." "Yellow" diff --git a/.claude-config/deploy.sh b/.claude-config/deploy.sh index f4007e2..e41c5af 100755 --- a/.claude-config/deploy.sh +++ b/.claude-config/deploy.sh @@ -8,8 +8,9 @@ # # What this script does (in order): # 1. Symlink ~/.claude/{skills,commands,agents,workflows} -> OPS sources -# 2. Mount the shared skills: clone the public skill source under PROJECTS/ -# when it is absent, then mirror SKILLS/VENDORED.tsv (bin/skills-vendor.sh) +# 2. (No step: deploy clones and mounts no skills. SKILLS/ reaches Claude Code +# through the step 1 link. The number stays so the docs that cite steps 7 +# and 8 by number stay right.) # 3. Link the always-loaded core: ~/.claude/rules/ops-core.md -> CONTEXT/core.md # 4. Strip the retired fleet wiring (PATH export in ~/.rc.local, the # old wrapper source line in a real ~/.zshrc or ~/.bashrc) @@ -47,7 +48,7 @@ NO_SYSTEM="${OPS_DEPLOY_NO_SYSTEM:-0}" for arg in "$@"; do case "$arg" in --no-system) NO_SYSTEM=1 ;; - -h|--help) sed -n '2,42p' "${BASH_SOURCE[0]}"; exit 0 ;; + -h|--help) sed -n '2,43p' "${BASH_SOURCE[0]}"; exit 0 ;; *) echo "deploy.sh: unknown argument: $arg (try --help)" >&2; exit 2 ;; esac done @@ -124,80 +125,6 @@ for entry in "${LINKS[@]}"; do fi done -# --- Mount the shared skills (clone the public source once, then sync) --- -# SKILLS/VENDORED.tsv lists the portable skills OPS mounts from the public -# Exploitacious/agent-skills repo (MIT); bin/skills-vendor.sh mirrors them from -# a clone under PROJECTS/ into SKILLS//. Without the clone a fresh install -# has none of the mounted skills, and with a clone but no sync the drift gate -# reads DRIFT. Deploy clones only when the source is absent and never pulls an -# existing clone: a re-deploy must not pull an unreviewed upstream HEAD into -# skills every session loads. Update deliberately: `git -C pull -# --ff-only`, then `skills-vendor.sh sync`. HTTPS, because a public repo needs -# no SSH key. Clone into a temporary sibling so a failed or interrupted clone -# cannot poison the canonical path and block the next deploy's retry. -echo "" -c_yel "Mounting shared skills..." -SKILLS_SOURCE_URL="https://github.com/Exploitacious/agent-skills.git" -SKILLS_SOURCE_DIR="${OPS_ROOT}/PROJECTS/Exploitacious/agent-skills" -SKILLS_VENDOR="${CONFIG_DIR}/bin/skills-vendor.sh" - -mount_skills() { - if [[ ! -r "${OPS_ROOT}/SKILLS/VENDORED.tsv" ]]; then - msg_bad "Cannot read SKILLS/VENDORED.tsv: mounted skills cannot be verified." - return 1 - fi - if ! grep -qE '^[^#[:space:]][^[:space:]]*[[:space:]]+Exploitacious/agent-skills/' "${OPS_ROOT}/SKILLS/VENDORED.tsv" 2>/dev/null; then - msg_ok "No mounted skills from Exploitacious/agent-skills in SKILLS/VENDORED.tsv" - return 0 - fi - if [[ -d "$SKILLS_SOURCE_DIR/.git" || -f "$SKILLS_SOURCE_DIR/.git" ]]; then - if ! git -C "$SKILLS_SOURCE_DIR" rev-parse --verify HEAD >/dev/null 2>&1; then - msg_bad "$SKILLS_SOURCE_DIR is an incomplete clone: move it aside, then re-run." - return 1 - fi - msg_ok "Skill source already cloned: $SKILLS_SOURCE_DIR (not pulled; see the comment above)" - elif [[ -e "$SKILLS_SOURCE_DIR" || -L "$SKILLS_SOURCE_DIR" ]]; then - msg_bad "$SKILLS_SOURCE_DIR exists but is not a git clone: move it aside, then re-run." - return 1 - elif ! command -v git >/dev/null 2>&1; then - msg_bad "git not found: cannot clone $SKILLS_SOURCE_URL. Mounted skills stay MISSING." - return 1 - else - local clone_tmp - if ! mkdir -p "${SKILLS_SOURCE_DIR%/*}" \ - || ! clone_tmp="$(mktemp -d "${SKILLS_SOURCE_DIR}.clone.XXXXXX")"; then - msg_bad "Cannot prepare a temporary skill-source clone." - return 1 - fi - if ! git clone --quiet "$SKILLS_SOURCE_URL" "$clone_tmp"; then - rm -rf -- "$clone_tmp" - msg_bad "Could not clone $SKILLS_SOURCE_URL (network?). Re-run deploy to retry." - return 1 - fi - # Rename onto a name that does not exist: plain mv does that identically on - # GNU and BSD/macOS (mv -T is GNU-only and broke every macOS deploy). A - # source that appeared during cloning is refused, never merged into; the - # temp must be gone afterward, or the rename did not happen. - if [[ -e "$SKILLS_SOURCE_DIR" || -L "$SKILLS_SOURCE_DIR" ]] \ - || ! mv -- "$clone_tmp" "$SKILLS_SOURCE_DIR" || [[ -e "$clone_tmp" ]]; then - rm -rf -- "$clone_tmp" - msg_bad "Skill source appeared during cloning: left $SKILLS_SOURCE_DIR unchanged. Re-run deploy." - return 1 - fi - msg_ok "Cloned $SKILLS_SOURCE_URL -> $SKILLS_SOURCE_DIR" - fi - if OPS_DIR="$OPS_ROOT" bash "$SKILLS_VENDOR" sync \ - && OPS_DIR="$OPS_ROOT" bash "$SKILLS_VENDOR" --check; then - # sync deliberately skips uncloned sources. A deploy must also prove every - # declared mount exists, rather than reporting success with missing skills. - msg_ok "Mounted skills synced and verified in ${OPS_ROOT}/SKILLS" - else - msg_bad "skills-vendor.sh sync failed: mounted skills are out of date (verify-ops reports DRIFT)." - return 1 - fi -} -mount_skills || DEPLOY_FAILED="$DEPLOY_FAILED skills-mount" - # --- The always-loaded core: ~/.claude/rules/ops-core.md -> CONTEXT/core.md --- # CONTEXT/core.md is the one file every session and lane must have loaded. # Claude Code loads every rule file in the user rules dir at launch, for every diff --git a/.claude-config/workflows/harness-audit.js b/.claude-config/workflows/harness-audit.js index b7383b8..253a11d 100644 --- a/.claude-config/workflows/harness-audit.js +++ b/.claude-config/workflows/harness-audit.js @@ -78,7 +78,7 @@ Questions: (1) Real bugs: quoting, TOCTOU, races, error swallowing, hardcoded pa { key: 'skills-audit', body: `LANE: SKILLS/ portfolio. -Files: every file in ~/OPS/SKILLS/ (each skill dir, README.md, VENDORED.tsv). A skill listed in VENDORED.tsv is a mirror of its source repo: audit it there, and flag any mirror that was edited by hand or any real SKILLS/ dir that duplicates a mounted one. Compare against any installed third-party plugin skills (~/.claude/plugins/: find its skills dir) for overlap. +Files: every file in ~/OPS/SKILLS/ (each skill dir, README.md, THIRD_PARTY_NOTICES.md). Flag any SKILLS/ dir left over from the retired skill mounts (DEPLOYMENT.md, "Leftovers from the skill mounts"). Compare against any installed third-party plugin skills (~/.claude/plugins/: find its skills dir) for overlap. Questions: (1) Per skill: does SKILL.md frontmatter/trigger description match what actually fires it; are internal file references valid; is the content stale vs current model policy (retired model names, obsolete context-window caps, credit-gate assumptions): quote each stale passage. (2) Does each skill hold only what a capable agent with a fresh context could not know (this copy's systems, house standards), or does it restate procedure the agent already knows? Name each passage that belongs in doctrine, a repo doc or a script instead. (3) session-handoff + pre-compact-synthesis: overlap between them, and vs native session-resume (--resume/--continue works across restarts): is any part now redundant? (4) Does any bundled workflow script use Date.now() or other calls the Workflow runtime bans? (5) Dual-track skills (SKILL.md + 00_System_Prompt.md GUI project): drift between the two tracks? (6) Is each skill's frontmatter current vs today's skill capabilities (allowed-tools, context: fork, agent field, hooks in skills, $ARGUMENTS)? (7) Missing skills the Operator obviously needs but lacks (base this on the doctrine + memory pointers you see, not speculation).`, }, { diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.yml index ffe37b5..18d0c21 100644 --- a/.github/workflows/gate.yml +++ b/.github/workflows/gate.yml @@ -195,10 +195,9 @@ jobs: with: persist-credentials: false - - name: Install bubblewrap, zsh, rsync and a current git, and prove bubblewrap can build a sandbox + - name: Install bubblewrap, zsh and a current git, and prove bubblewrap can build a sandbox # sandbox-run needs a root-owned bwrap. One root-wrapper case runs in zsh - # (it prints SKIP without it), and the skill-mount tests exercise the - # rsync engine as well as the tar fallback. branch-gc reads `git rev-parse + # (it prints SKIP without it). branch-gc reads `git rev-parse # --show-ref-format` (git 2.45) and skips every repository without it; # Ubuntu 24.04's own git is 2.43, so an older git is upgraded from the # git-core PPA (the 26.04 runner image already ships 2.55, so this is @@ -211,7 +210,7 @@ jobs: # hide a broken gate. run: | need=() - for pkg in bubblewrap:bwrap zsh:zsh rsync:rsync; do + for pkg in bubblewrap:bwrap zsh:zsh; do command -v "${pkg#*:}" >/dev/null 2>&1 || need+=("${pkg%%:*}") done git_ok() { [ "$(printf '%s\n2.45\n' "$(git --version | awk '{print $3}')" | sort -V | head -n 1)" = 2.45 ]; } diff --git a/.gitignore b/.gitignore index 831b68d..cdf6c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,9 +30,6 @@ desktop.ini # --- OPS machine-local churn --- .claude-config/backup/sync.log -# skills-vendor.sh staging dirs: an interrupted sync leaves one, and the next -# sync cleans it; until then the daily backup must not commit a mirror copy. -SKILLS/.vendor.*/ # Claude Code syncs claude.ai org and Anthropic skills into ~/.claude/skills/synced, and # deploy.sh links ~/.claude/skills to SKILLS/. Those skills belong to the org and refresh at # every session start; the daily backup's `git add -A` would commit them into this repo. diff --git a/AGENTS.md b/AGENTS.md index e0b31c1..5e809e5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,11 +66,10 @@ current task allows. ## Conventions -- `SKILLS/` is the single source for skills, deployed through the - `~/.claude/skills/` symlink. Mounted entries (`SKILLS/VENDORED.tsv`) are - edited at their source repo and synced with - `.claude-config/bin/skills-vendor.sh`; never edit the mirror or - `~/.claude/skills/` directly. +- `SKILLS/` is the single source for the template's skills, deployed through + the `~/.claude/skills/` symlink; edit them here, never in + `~/.claude/skills/`. An organization's shared skills are delivered + separately by that organization, not through this repo. - `.claude-config/`, `.claude-memory/`, and `.claude-handoffs/` are literal names; do not rename them. - Personalization lives only in the files `harness-update` never syncs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 2275e37..776f25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,30 @@ Notable changes to OPS, newest first. Format: the date, then what changed and wh matters. This file starts fresh at the public release; the harness's private prehistory is deliberately not part of it. +## 2026-11-17: the skill mounts retire + +The template mounted no skills once `SKILLS/VENDORED.tsv` lost its last row, yet the +deployers still carried the step that cloned the public `agent-skills` repo and synced +mirrors from it. The mechanism goes: the template +ships its own harness skills in `SKILLS/`, and an organization's shared skills are +delivered separately by that organization. + +- **Removed**: `.claude-config/bin/skills-vendor.sh`, `SKILLS/VENDORED.tsv`, and the + suites `tests/skills-vendor-test.sh` and `tests/deploy-skills-mount-test.sh`. +- **`deploy.sh` and `deploy.ps1`** no longer clone a skill source or sync mirrors, and + no longer record a `skills-mount` failure. `deploy.sh` keeps its step numbers (step 2 + is now a note), because the docs and the session briefing cite steps 7 and 8; + `deploy.ps1` renumbers its last two steps. +- **`verify-ops.sh`**: check 22 (mirror drift) is retired, its number left free; + `skills-vendor.sh` leaves the destructive-tool list of check 24; checks 4 and 9b no + longer read a manifest. The self-test and `deploy-windows-test.ps1` lose their + mount cases; CI no longer installs rsync, which only the mount tests used. +- **An existing copy keeps its leftovers**, since neither deploy nor a template sync + deletes files: the clone under `PROJECTS/`, the mirrored `SKILLS//` folders, + `SKILLS/.vendored-state.tsv`. `DEPLOYMENT.md`, "Leftovers from the skill mounts", + says how to recognise them; all are safe to remove by hand, and `verify-ops.sh` + warns that the clone is missing from `projects-map.md` until it is gone. + ## 2026-11-17: skills hold facts, not procedure; twelve template skills retire The owner cut the skill set with one test: a skill holds only what a capable agent with diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 66204be..e70847e 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -14,7 +14,7 @@ Stage 2 automatically; there is no manual step between them. | Stage | Owner | Repo | What it does | |-------|-------|------|--------------| | **1. Host setup** | `shellSetup.sh` / `winSetup.ps1` | `linuxploitacious` (public) | OS packages, dotfiles via Stow, AI CLI install, `gh` auth, Level 1 Claude files (`CLAUDE.md`, `settings.json`, `statusline.sh`), clone your private OPS copy, **then invoke Stage 2**. | -| **2. OPS setup** | `.claude-config/deploy.sh` (Linux/macOS) / `deploy.ps1` (Windows) | your private OPS copy | Symlink `~/.claude/{skills,commands,agents,workflows}`. Mount the shared skills. Link the always-loaded core into `~/.claude/rules/`. Strip the retired fleet wiring. Wire the root wrapper. Write the ultracode shim. Initialize auto-memory git-sync. Schedule daily backup. Report the caveman and ponytail plugins (never removes them). Seed the trust anchor. | +| **2. OPS setup** | `.claude-config/deploy.sh` (Linux/macOS) / `deploy.ps1` (Windows) | your private OPS copy | Symlink `~/.claude/{skills,commands,agents,workflows}`. Link the always-loaded core into `~/.claude/rules/`. Strip the retired fleet wiring. Wire the root wrapper. Write the ultracode shim. Initialize auto-memory git-sync. Schedule daily backup. Report the caveman and ponytail plugins (never removes them). Seed the trust anchor. | Rule: **anything OPS-specific lives in Stage 2.** linuxploitacious clones the repo and hands off; it does not configure OPS itself. @@ -143,20 +143,12 @@ In order: `.claude-config/{commands,agents,workflows}/`. Any real dir already at a target is backed up, not clobbered. -2. **Mount the shared skills.** `SKILLS/VENDORED.tsv` lists the portable skills - OPS mounts from the public - [`Exploitacious/agent-skills`](https://github.com/Exploitacious/agent-skills) - repo. When `PROJECTS/Exploitacious/agent-skills` is absent, deploy clones it - over HTTPS, then runs `.claude-config/bin/skills-vendor.sh sync` to mirror - each listed skill into `SKILLS//` (rsync where installed, tar - otherwise, so a minimal container needs no extra package). Deploy never - pulls an existing clone: a re-deploy must not pull an unreviewed upstream - change into skills every session loads. Update on purpose: - `git -C ~/OPS/PROJECTS/Exploitacious/agent-skills pull --ff-only`, then - `~/OPS/.claude-config/bin/skills-vendor.sh sync`. A failed clone (no - network) prints an `[XX]` line and fails the deploy (`skills-mount`); - `verify-ops.sh` warns that the mounts are MISSING until a re-run clones - them. +2. **No skill step.** The template's harness skills ship in `SKILLS/` and reach + Claude Code through the step 1 link; deploy clones and mounts nothing. An + organization's shared skills are delivered separately by that organization. + (Until 2026-11-17 this step cloned a public skill source; "Updating an + existing deploy" says what that left behind. The later steps keep their + numbers.) 3. **Link the always-loaded core** into `~/.claude/rules/ops-core.md` (see "How the core loads"). A regular file in the way is backed up under a name Claude @@ -309,8 +301,7 @@ which is tied to the public linuxploitacious repo); the git identity check (`bin\memory-init.ps1`, behind the same push gate as step 8); the trust anchor; the ultracode shim in the seam; an `OPS Daily Backup` scheduled task that runs `daily-sync.sh` in Git Bash (skipped with `-NoSystem`; registered -with or without an `origin` remote, as on Linux); the skill mount -(clone, then `skills-vendor.sh sync` through Git Bash); the plugin report (same +with or without an `origin` remote, as on Linux); the plugin report (same CLI reads as step 9); and a Git Bash pin plus the guard self-test (its `--quick` probe set, with a line saying it is running, because the full set is slow under Git Bash). @@ -326,9 +317,8 @@ After the script finishes: # The core loads on every launch path (expect: the path of CONTEXT/core.md) readlink -f ~/.claude/rules/ops-core.md -# Skills resolve, and every mounted skill matches its source (expect: OK lines only) +# Skills resolve diff <(ls ~/.claude/skills/) <(ls ~/OPS/SKILLS/) # empty diff == correct -~/OPS/.claude-config/bin/skills-vendor.sh --check # Deploy reported, and did not remove, any caveman or ponytail plugin # (remove one yourself only if you choose: the commands are in its warning) @@ -382,9 +372,7 @@ The `curl` line fetches the Stage-1 settings a new host has; the git identity is the prerequisite from step 7. Expect `Deploy complete.` and, on the last line of the gate, `verify-ops: ok · 0 warn · 0 fail ()`, with both commands exiting 0. `--no-system` keeps deploy off your crontab and root's -rc files. Deploy still clones the public skill source over HTTPS, so the test -needs network access, and the throwaway directory stays in your temp dir until -you delete it. +rc files. The throwaway directory stays in your temp dir until you delete it. Do not drop the `set-url --push` line when you clone a URL. Deploy's memory sync commits to the copy and pushes it whenever the push gate finds origin private, @@ -489,8 +477,8 @@ Stage 2 deploy scripts. `/compact` (T3 Code's composer, or the terminal). - **Destructive-tool tests run in a sandbox:** every suite that runs a tool - that deletes or moves files (branch-gc, pre-compact, memory-init, deploy, - skills-vendor) refuses to start outside `.claude-config/bin/sandbox-run`, + that deletes or moves files (branch-gc, pre-compact, memory-init, deploy) + refuses to start outside `.claude-config/bin/sandbox-run`, which needs `bwrap` (bubblewrap; `apt install bubblewrap`). `verify-ops.sh` check 24 fails a suite that names one of those tools without the guard; `.claude-config/bin/README.md` ("sandbox-run") has the @@ -569,6 +557,17 @@ bash ~/OPS/.claude-config/deploy.sh # or deploy.ps1 on Windows Stage 2 is idempotent: it no-ops where state is already correct. +### Leftovers from the skill mounts (copies older than 2026-11-17) + +Before 2026-11-17, deploy cloned a public skill source into +`PROJECTS/Exploitacious/agent-skills` and mirrored skills from it into +`SKILLS/`. Neither deploy nor a template sync deletes files, so an older copy +keeps them, and all are safe to remove by hand: the clone (`verify-ops.sh` +warns that it is absent from `projects-map.md` until it is gone); each +`SKILLS//` folder in the first column of `SKILLS/.vendored-state.tsv`, +then that file (keep any folder from a mount row you added yourself); and any +`SKILLS/.vendor.XXXXXX` staging folder. + ### Upgrading from a copy older than 2026-11-07 The 2026-11-07 release split the always-loaded core. The rules that bind only @@ -604,7 +603,7 @@ the code; it never copies your identity files in either direction): 1. **Re-run Stage 2.** `bash ~/OPS/.claude-config/deploy.sh` links the core into `~/.claude/rules/`, replaces the boot shim in your `.local` files (keeping a Round F `--settings` edit), strips the fleet PATH and wrapper - lines, mounts the shared skills, and runs the ported `memory-init`. + lines, and runs the ported `memory-init`. 2. **Create the new identity files from the template**, then move your content into them. From the OPS root: ```bash @@ -669,18 +668,6 @@ and re-run Stage 2: discloses what Stage 1 sets; `BOOTSTRAP.md` Round F shows how to keep them or switch to normal permission prompts without editing the Stage-1 file. -## Known limits - -- **The nightly backup pulls the public skill source.** The backup's project - stage runs `PROJECTS/sync-check.sh --auto`, which fast-forwards every clean - clone under `PROJECTS/`, including `PROJECTS/Exploitacious/agent-skills`. - Deploy never pulls that clone (step 2), but once the backup has pulled an - upstream change to a mounted skill, `verify-ops.sh` reports one fail, - `skills mirror DRIFT`, until the mirror is synced, and the next `deploy.sh` - syncs whatever the backup pulled, reviewed or not. Read what changed - (`git -C ~/OPS/PROJECTS/Exploitacious/agent-skills log -p` over the new - commits), then run `~/OPS/.claude-config/bin/skills-vendor.sh sync`. - ## What stays out of these scripts Explicitly NOT handled by Stage 2 (`deploy.sh` / `deploy.ps1`): @@ -729,7 +716,6 @@ If a new piece of OPS setup needs to run on every host: - `.claude-config/bin/verify-ops.sh`: the drift gate. - `.claude-config/bin/claude-root-wrapper.sh`: root permission mode and shared-host lock (Linux). - `.claude-config/bin/memory-init`, `memory-init.ps1`, `memory-index`: auto-memory git-sync and its index. -- `.claude-config/bin/skills-vendor.sh`, `SKILLS/VENDORED.tsv`: the skill mounts. - `.claude-config/bin/tests/`: the tests for the above. - `.github/workflows/gate.yml`: the CI gate (syntax checks, every suite, a fresh-install smoke test with `verify-ops.sh`, a secrets scan); it runs on the template repository only. - `SKILLS/THIRD_PARTY_NOTICES.md`: the third-party works the skills adapt, and their licenses. diff --git a/PROJECTS/projects-map.md b/PROJECTS/projects-map.md index 9dd4e4e..56e65ac 100644 --- a/PROJECTS/projects-map.md +++ b/PROJECTS/projects-map.md @@ -71,23 +71,9 @@ are tracked. Each project repo (`//`) manages its own git. |---------|---------| | `ExampleOrg/` | *(example)* your primary body of work: swap for your real org. | | `AnotherOrg/` | *(example)* a second cluster, added when a distinct body of work earns one. | -| `Exploitacious/` | Shipped: holds the public skill source `deploy.sh` clones (`agent-skills/`). | -On a fresh copy there is one example cluster plus the skill-source cluster -deploy creates. Add rows here as you create real clusters, and give each its -own section below. - ---- - -## Cluster: Exploitacious (skill source, deploy-managed) - -| Repo | Role | Stack | Deploys to | -|------|------|-------|------------| -| `agent-skills/` | Public source of the mounted skills in `SKILLS/VENDORED.tsv`; `deploy.sh` clones it once, `skills-vendor.sh sync` mirrors it into `SKILLS/` | Markdown skills | `SKILLS//` (mirror) | - -Edit a mounted skill at this source (or upstream), never in its `SKILLS/` -mirror; update with `git -C PROJECTS/Exploitacious/agent-skills pull --ff-only` -and then `.claude-config/bin/skills-vendor.sh sync`. +On a fresh copy there is one example cluster. Add rows here as you create +real clusters, and give each its own section below. --- diff --git a/README.md b/README.md index 1327e7f..dc1cf63 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ What it gives you, out of the box: scripts. The template ships the few that bind to OPS's own hooks and layout: pre-compact synthesis, session lifecycle, file transfer, inline T3 pages and template sync. A shared skill lives in exactly one repo, so the template - mounts none by default; an org or private source mounts through - `SKILLS/VENDORED.tsv`. See `SKILLS/README.md`. + carries none; an organization delivers its own shared skills separately. See + `SKILLS/README.md`. ## Opinionated by design @@ -208,7 +208,8 @@ idempotent and safe to re-run after any pull. On Linux, in order: 1. Link `~/.claude/{skills,commands,agents,workflows}` to the matching OPS directories, backing up any real directory already there. -2. Mount the shared skills (see "Skill mounts"). +2. No skill step: `SKILLS/` arrives through the step 1 link (see "Shared + skills"). The later steps keep their numbers. 3. Link the always-loaded core into `~/.claude/rules/ops-core.md`. 4. Strip the retired fleet's PATH and wrapper lines from your shell rc files (whole-line matches only; anything you wrote stays). @@ -297,24 +298,16 @@ private GitHub remote (`git -C ~/OPS remote add origin `, see the push gate above); the next run pulls and pushes every local commit. An origin that exists but cannot be reached is still a failed pull, reported as an error. -## Skill mounts - -Shared skills are mounted, not copied. `SKILLS/VENDORED.tsv` lists each -mounted skill and its source; since 2026-11-17 the template ships it with no -rows (it used to mount nine from -[`Exploitacious/agent-skills`](https://github.com/Exploitacious/agent-skills), -which the owner ruled out of the template). Deploy still clones that repo once under -`PROJECTS/Exploitacious/agent-skills` (it never pulls an existing clone, so a -re-deploy cannot slip in an unreviewed upstream change), then runs -`.claude-config/bin/skills-vendor.sh sync` to mirror each skill into -`SKILLS//`. Edit a mounted skill at its source repo, never in `SKILLS/`. -`skills-vendor.sh --check` prints `OK`, `DRIFT` (the source changed and the -mirror did not), or `MISSING` (the source is not cloned). The sync never -deletes a folder it did not write: your own skill under a mounted name, or a -hand-edited mirror, moves to `.claude-config/backup/skills-replaced/` first. -Add a row to `VENDORED.tsv` for an org or private source of your own -(`SKILLS/README.md`). Third-party work the template adapts is listed with its -license in [`SKILLS/THIRD_PARTY_NOTICES.md`](SKILLS/THIRD_PARTY_NOTICES.md). +## Shared skills + +The template ships its own harness skills in `SKILLS/`, and deploy links that +folder to `~/.claude/skills/`. An organization's shared skills are delivered +separately by that organization: a shared skill lives in exactly one repo, so +the template carries no copy. Until 2026-11-17 deploy cloned a public skill +source and mirrored skills from it; `DEPLOYMENT.md`, "Leftovers from the skill +mounts", says what an older copy may still hold. Third-party work the template +adapts is listed with its license in +[`SKILLS/THIRD_PARTY_NOTICES.md`](SKILLS/THIRD_PARTY_NOTICES.md). ## Template sync @@ -351,7 +344,7 @@ origin (`CONTEXT/how-i-work.md`, "The template and a copy's owner"). - **The drift gate:** `bash ~/OPS/.claude-config/bin/verify-ops.sh` machine-checks the conventions that used to live only in prose: the core's - size and link, the model pins, the retired files, the skill mounts, the + size and link, the model pins, the retired files, the skill sizes, the sandbox guards, and more. Exit 0 means no FAIL (a WARN is advice). `--quiet` prints only WARN and FAIL lines, and `OPS_DIR=` checks another checkout. Its host checks read `$HOME` (the core link, the Stage-1 @@ -391,13 +384,13 @@ OPS/ │ └── projects/ # per-project lessons, loaded only when on that project ├── SKILLS/ # Claude Code Skills + GUI Project twins (symlinked -> ~/.claude/skills/); THIRD_PARTY_NOTICES.md ├── .claude-config/ # Stage 2 deploy + the machinery it does not itself install -│ ├── deploy.sh / deploy.ps1 # Stage 2 deployer (links, core rule, skill mounts, memory sync, ...) +│ ├── deploy.sh / deploy.ps1 # Stage 2 deployer (links, core rule, memory sync, ...) │ ├── hooks/ # SessionStart briefing + foreman doctrine + lane rules + memory digest, pre-compact snapshot + branch-gc + │ │ # tool re-select, context-watch, memory hint, report-lint, askuser-cancel, secrets/git guards │ ├── systemd/ # ops-verify timer (nightly drift gate) + optional tmux-main │ ├── remote-sessions/ # hand-run tmux sessions you remote-control (see its README) │ ├── agents/ + workflows/ # sub-agent definitions + multi-lane workflow scripts -│ └── bin/ # memory-index/-init, branch-gc, sandbox-run, verify-ops, skills-vendor, lane-class, await, tests/ (and more) +│ └── bin/ # memory-index/-init, branch-gc, sandbox-run, verify-ops, lane-class, await, tests/ (and more) ├── .claude-memory/ # per-machine memory pools (git-synced via bin/memory-init; loaded natively or by the digest hook) ├── .claude-handoffs/ # cross-session / cross-machine handoff batons ├── PROJECTS/ # your working repos (2nd-level subdirs are their own repos, gitignored) @@ -446,8 +439,6 @@ For a forker, this means: - **Rest-stop cadence.** Compaction is a rest stop, not a scarcity response: compact by hand at natural breaks (foreman.md § "Rhythm and compaction"); auto-compaction is the backstop. -- **Mount portable skills.** `deploy.sh` clones the public skill source and - runs `.claude-config/bin/skills-vendor.sh sync`; see `SKILLS/README.md`. - **The drift gate checks it.** `verify-ops.sh` fails if the core is missing, over budget, or not linked (check 16), if a root `CLAUDE.md` would hide `AGENTS.md` (1b), if `USER.md` is still the template on a bootstrapped copy diff --git a/SKILLS/README.md b/SKILLS/README.md index 16e357e..b4a5685 100644 --- a/SKILLS/README.md +++ b/SKILLS/README.md @@ -1,6 +1,6 @@ # SKILLS: source library for Claude skills and GUI projects -This folder is the **authoritative source** for the local, OPS-specific Claude capabilities the Operator maintains across machines. A skill holds only what a capable agent with a fresh context could not know (this copy's systems, house standards), never procedure: a behavior rule goes to doctrine (`CONTEXT/core.md`), a repo fact to the repo, a mechanical step to a script or tool. Shared skills are mounted from their one source repo instead (see "Skill sources" below). Each subfolder is one "library entry" that can deploy in two places: +This folder is the **authoritative source** for the local, OPS-specific Claude capabilities the Operator maintains across machines. A skill holds only what a capable agent with a fresh context could not know (this copy's systems, house standards), never procedure: a behavior rule goes to doctrine (`CONTEXT/core.md`), a repo fact to the repo, a mechanical step to a script or tool. Shared skills come from their one source repo instead (see "Skill sources" below). Each subfolder is one "library entry" that can deploy in two places: 1. **Claude Code (CLI)**: as a Skill, lazy-loaded by trigger description. Deployed via `~/.claude/skills/` symlinked directly to this folder. One hop. Cross-platform via `.claude-config/deploy.ps1` (Windows) or `.claude-config/deploy.sh` (Linux/macOS). 2. **Claude.ai GUI (web/desktop/mobile)**: as a Project. Files uploaded manually into a project's instructions field plus knowledge file slots. @@ -33,21 +33,11 @@ The `SKILL.md` and the `0X_*.md` knowledge files share content but serve differe ## Skill sources -A shared skill lives in exactly one repo, and every copy that uses it mounts it from there rather than carrying a drifting fork; a template copy of a same-named skill would block the shared one. What lives in *this* `SKILLS/` folder directly is the local, distribution-specific set: glue that binds to OPS's own hooks, scripts, and layout. On 2026-11-17 the template removed its thin context skills (the core's "Where to look" table names those files directly), its two generic method skills, and the skills that restated what a capable agent already knows. - -**The mount mechanism is `.claude-config/bin/skills-vendor.sh` + `VENDORED.tsv`** (one mechanism, not two). `VENDORED.tsv` lists each portable skill and its source dir under `PROJECTS/`; `skills-vendor.sh sync` mirrors those source dirs into `SKILLS//`, and `skills-vendor.sh --check` is the drift gate `verify-ops.sh` runs (DRIFT = a source edit not mirrored = FAIL; MISSING = source repo not cloned = WARN). The template ships `VENDORED.tsv` with no rows: its nine rows for [`github.com/Exploitacious/agent-skills`](https://github.com/Exploitacious/agent-skills) were removed on 2026-11-17. Add rows for an org or private source of your own. To mount: clone the source under `PROJECTS//`, add one row per skill, then sync: - -``` -~/OPS/.claude-config/bin/skills-vendor.sh sync -``` - -Never hand-edit a mirrored `SKILLS//` dir; the sync replaces it. The sync never deletes a folder it did not write: a destination that is not a mirror it recorded in `SKILLS/.vendored-state.tsv` (your own skill under a name a manifest row now mounts, or a hand-edited mirror) is moved to `.claude-config/backup/skills-replaced/-/` first, and the sync prints a `BACKUP` line naming that path. On a fresh fork the source repos are not cloned, so the mounted skills appear only after the clone and the sync. Until you clone, `skills-vendor.sh --check` reports them MISSING (a WARN). Once the source is cloned, an un-synced mount reads as DRIFT (a FAIL) until you run `sync`. - -The clone's checked-out commit is what a mount follows, and deploy never pulls an existing clone, so a newer source release reaches your copy only when you move it on purpose: read what changed (`git -C ~/OPS/PROJECTS// fetch`, then `log -p HEAD..origin/main`), `git -C ~/OPS/PROJECTS// pull --ff-only`, then `skills-vendor.sh sync` and `skills-vendor.sh --check`. `VENDORED.tsv` has no version column; the commit you pulled is the pin. +A shared skill lives in exactly one repo; a template copy of a same-named skill would block the shared one. What lives in *this* `SKILLS/` folder is the template's own set: glue that binds to OPS's own hooks, scripts, and layout. An organization's shared skills are delivered separately by that organization, not through this repo. On 2026-11-17 the template removed its thin context skills (the core's "Where to look" table names those files directly), its two generic method skills, and the skills that restated what a capable agent already knows, and deploy stopped cloning and mirroring a public skill source (`DEPLOYMENT.md`, "Leftovers from the skill mounts", lists what an older copy may still hold). ## How to add a new entry -First route the knowledge (`CONTEXT/core.md`, "Memory and where knowledge goes"): a client fact to the documentation system, a repo fact to the repo, a behavior rule to doctrine, a mechanical step to a script or tool. Only what fits none of those becomes a skill. When a `meta-skill-creator` skill is mounted from a shared source, it says how to build one; the template no longer ships it. +First route the knowledge (`CONTEXT/core.md`, "Memory and where knowledge goes"): a client fact to the documentation system, a repo fact to the repo, a behavior rule to doctrine, a mechanical step to a script or tool. Only what fits none of those becomes a skill. When your organization delivers a `meta-skill-creator` skill, it says how to build one; the template no longer ships it. ## Deployment @@ -71,7 +61,7 @@ The script is idempotent, so it is safe to re-run anytime. ## Index -Local entries live in this folder. The template mounts none; a skill you mount appears in `SKILLS/` only after `skills-vendor.sh sync`. +Local entries live in this folder. | Entry | Deployed as Skill? | GUI Project? | Notes | |-------|--------------------|--------------|-------| @@ -92,7 +82,7 @@ Every model-invocable skill puts its name and description into the listing each - `disable-model-invocation: true` in a skill's frontmatter (a standalone `#` comment line or a trailing comment beside it parses) drops the skill from the model's listing and leaves only the human `/name` command; the model cannot load it through the Skill tool. It suits a skill the operator starts by name. The template ships it on `harness-update`: a template sync starts only when the operator asks, so its description bought nothing in the listing. Type `/harness-update` to run it; asked in plain words, an agent cannot load it through the Skill tool. To give the model that skill back, delete the line in your copy. Probed on Claude Code 2.1.319. An edit to a template skill's frontmatter is a local change: `harness-update` reports that file as a CONFLICT if upstream later changes it too. - The `skillOverrides` setting in your own Claude Code settings (`{"": "on" | "name-only" | "user-invocable-only" | "off"}`) changes how a skill is listed without editing its file, and also covers built-in and account skills. A `Skill(...)` permission deny does not hide a skill from the listing. `deploy.sh` never writes your settings, so this one is entirely yours. -- A skill you never load can be deleted, local or mounted. For a mounted one, delete its row in `VENDORED.tsv` and its `SKILLS//` mirror folder: the sync writes mirrors and never removes one, so a dropped row leaves its folder in place. +- A skill you never load can be deleted from your copy. ## Migrating a cloud-only Project diff --git a/SKILLS/THIRD_PARTY_NOTICES.md b/SKILLS/THIRD_PARTY_NOTICES.md index 7ffc3a0..45b3da4 100644 --- a/SKILLS/THIRD_PARTY_NOTICES.md +++ b/SKILLS/THIRD_PARTY_NOTICES.md @@ -22,9 +22,8 @@ referenced ideas; no text from those works is copied. On 2026-11-17 the template stopped shipping the skills that adapted the other works this file used to list (mattpocock/skills, ayghri/i-have-adhd and anthropics/skills `frontend-design`): the `operating-model` and `design-method` -skills were removed, and `SKILLS/VENDORED.tsv` no longer mounts the -`Exploitacious/agent-skills` set. A source you mount yourself carries its own -notices. +skills were removed, and the template no longer mounts skills from another +repository. A skill you add from another source carries its own notices. ## What the license asks diff --git a/SKILLS/VENDORED.tsv b/SKILLS/VENDORED.tsv deleted file mode 100644 index 6f26e46..0000000 --- a/SKILLS/VENDORED.tsv +++ /dev/null @@ -1,34 +0,0 @@ -# VENDORED.tsv - manifest for skills-vendor.sh (the OPS skill-mount mechanism). -# -# OPS mounts portable technique skills rather than carrying a drifting fork of -# each. The skill repos cloned under PROJECTS/ are the source of truth; this file -# lists which skill dirs are mirrored into SKILLS/ and from where. Edit a vendored -# skill at its source repo, then run `skills-vendor.sh sync` to refresh the mirror -# here. Never hand-edit the mirrored SKILLS// dirs; the sync replaces them. -# A folder the sync did not write (your own skill under a name a row mounts, or -# a hand-edited mirror) is moved to .claude-config/backup/skills-replaced/ first, -# never deleted; SKILLS/.vendored-state.tsv records what the sync wrote. -# -# Format: one row per skill, tab-separated: -# -# The mirror lands at ~/OPS/SKILLS//. Lines starting with # and blank lines -# are ignored. The drift gate is `skills-vendor.sh --check`, wired into -# verify-ops.sh (DRIFT = FAIL, MISSING = WARN). -# -# To mount a source, clone it under PROJECTS// first, add a row per -# skill below, then run: skills-vendor.sh sync -# -# The template ships no rows (2026-11-17). Its nine rows mounted the public -# Exploitacious/agent-skills set; the owner ruled those skills out of the -# template, because a shared skill lives in exactly one repo, and a template copy -# of a same-named skill (meta-skill-creator was one) blocks the shared one. -# Add rows for an org or private source of your own below, one per skill. -# -# Versions: this file has no version column. A mount follows the checked-out -# commit of its source clone, and deploy never pulls an existing clone, so you -# move to a newer release on purpose (SKILLS/README.md, "Skill sources"). -# -# Every mounted skill costs its description in each session's skill listing -# (SKILLS/README.md, "The skill listing budget"). To stop mounting one, delete its -# row and its SKILLS// mirror folder: sync writes mirrors and never removes -# one. From 4f0c8493579ddf02b9fb6dc3f515127a23ecc6e8 Mon Sep 17 00:00:00 2001 From: Alex Ivantsov Date: Tue, 17 Nov 2026 20:39:59 -0500 Subject: [PATCH 2/2] fix(skills): keep the staging ignore rule and make the leftovers note safe --- .claude-config/bin/verify-ops-selftest.sh | 12 ++++++++++-- .gitignore | 3 +++ CHANGELOG.md | 8 +++++--- DEPLOYMENT.md | 24 ++++++++++++++++++----- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.claude-config/bin/verify-ops-selftest.sh b/.claude-config/bin/verify-ops-selftest.sh index 6c1fca2..18386c2 100755 --- a/.claude-config/bin/verify-ops-selftest.sh +++ b/.claude-config/bin/verify-ops-selftest.sh @@ -9,7 +9,7 @@ # against current Stage-1-shaped settings, and fail on each class they exist to # catch. It also pins the shipped .gitattributes rule that merges pool # MEMORY.md indexes with the union driver, and the shipped .gitignore rules -# that keep SKILLS/synced and SKILLS/.trash out of the repo. +# that keep SKILLS/synced, SKILLS/.trash and retired mount staging out of the repo. # # Sources verify-ops.sh (its main runs only when executed) and drives single # checks against fixture trees under a throwaway HOME made by mktemp. It never @@ -445,6 +445,14 @@ run check_skills_index chk "untracked synced and .trash dirs -> no WARN" "$([ "$WARNS" = 0 ]; echo $?)" chk "the shipped .gitignore ignores SKILLS/synced" "$(git -C "$OPS" check-ignore -q SKILLS/synced/org-skill/SKILL.md; echo $?)" chk "the shipped .gitignore ignores SKILLS/.trash" "$(git -C "$OPS" check-ignore -q SKILLS/.trash/old-org-skill/SKILL.md; echo $?)" +# An interrupted mount can leave the only copy of local files in previous/. +# Retiring its writer must not make the daily backup commit that staging tree. +mkdir -p "$OPS/SKILLS/.vendor.Ab12Cd/previous" +printf 'local setup\n' > "$OPS/SKILLS/.vendor.Ab12Cd/previous/SETUP.md" +chk "the shipped .gitignore ignores retired mount staging" \ + "$(git -C "$OPS" check-ignore -q SKILLS/.vendor.Ab12Cd/previous/SETUP.md; echo $?)" +chk "ordinary local skills remain trackable" \ + "$(git -C "$OPS" check-ignore -q SKILLS/local-skill/SKILL.md; [ "$?" = 1 ]; echo $?)" git -C "$OPS" add -f SKILLS/synced/org-skill/SKILL.md git -C "$OPS" -c user.name=selftest -c user.email=selftest@example.invalid commit -q -m fixture run check_skills_index @@ -567,7 +575,7 @@ run memory_checks chk "the shipped memory-index on a small pool -> no FAIL, no WARN" "$([ "$FAILS" = 0 ] && [ "$WARNS" = 0 ]; echo $?)" # 29. Skill size (9b): 16,384 bytes and 1,500 characters a line, both -# inclusive; WARN only. Mounted, synced and symlinked skills are skipped, and the +# inclusive; WARN only. Synced and symlinked skills are skipped, and the # shipped skills pass. mk_skill() { # name bytes [longest_line_chars] local d="$OPS/SKILLS/$1"; mkdir -p "$d" diff --git a/.gitignore b/.gitignore index cdf6c1b..6ec497c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,9 @@ desktop.ini # --- OPS machine-local churn --- .claude-config/backup/sync.log +# Retired skill mounts can leave staging with the only copy of local files. +# Keep it out of the daily backup until the owner recovers and removes it. +SKILLS/.vendor.*/ # Claude Code syncs claude.ai org and Anthropic skills into ~/.claude/skills/synced, and # deploy.sh links ~/.claude/skills to SKILLS/. Those skills belong to the org and refresh at # every session start; the daily backup's `git add -A` would commit them into this repo. diff --git a/CHANGELOG.md b/CHANGELOG.md index 776f25b..f0b9952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,9 +24,11 @@ delivered separately by that organization. mount cases; CI no longer installs rsync, which only the mount tests used. - **An existing copy keeps its leftovers**, since neither deploy nor a template sync deletes files: the clone under `PROJECTS/`, the mirrored `SKILLS//` folders, - `SKILLS/.vendored-state.tsv`. `DEPLOYMENT.md`, "Leftovers from the skill mounts", - says how to recognise them; all are safe to remove by hand, and `verify-ops.sh` - warns that the clone is missing from `projects-map.md` until it is gone. + `SKILLS/.vendored-state.tsv`, and any interrupted staging under `SKILLS/.vendor.*/`. + `DEPLOYMENT.md`, "Leftovers from the skill mounts", says how to inspect them and + preserve local work before optional removal. Staging remains gitignored so the + daily backup does not commit it, and `verify-ops.sh` warns that the clone is + missing from `projects-map.md` until it is gone. ## 2026-11-17: skills hold facts, not procedure; twelve template skills retire diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index e70847e..24ea482 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -562,11 +562,25 @@ Stage 2 is idempotent: it no-ops where state is already correct. Before 2026-11-17, deploy cloned a public skill source into `PROJECTS/Exploitacious/agent-skills` and mirrored skills from it into `SKILLS/`. Neither deploy nor a template sync deletes files, so an older copy -keeps them, and all are safe to remove by hand: the clone (`verify-ops.sh` -warns that it is absent from `projects-map.md` until it is gone); each -`SKILLS//` folder in the first column of `SKILLS/.vendored-state.tsv`, -then that file (keep any folder from a mount row you added yourself); and any -`SKILLS/.vendor.XXXXXX` staging folder. +keeps them. Inspect them before choosing what to remove; keep skills and +sources you added yourself. + +- `SKILLS/.vendored-state.tsv` lists old mirror names in its first column. + A listed `SKILLS//` folder can have changed since its digest was + recorded. Compare it with its source and preserve any local edits and + GUI-only files (`00_System_Prompt.md`, `05_gui_dual_track.md`, `SETUP.md`) + before removing an unwanted mirror. Keep the ledger until that review is done. +- `SKILLS/.vendor.XXXXXX` is staging from an interrupted sync. Its `previous/` + or `tree/` can hold the only copy of local or GUI files, including a mirror + that is missing from `SKILLS/`. Recover or save those files before removing + staging. These directories remain gitignored so the daily backup does not + commit them while they await review. +- Check `PROJECTS/Exploitacious/agent-skills` for uncommitted work and unpushed + commits before removing the clone, after reviewing its mirrors. + `verify-ops.sh` warns that it is absent from `projects-map.md` until it is gone. + +Once you have preserved the files you want and removed unwanted mirrors, the +old ledger can be removed too. ### Upgrading from a copy older than 2026-11-07