test-muse-bridge-safety.sh
bash
sha256:8d46372e39d2d5a54fd93a8b1c27922fe0d9b22a72197345f1d2c71701cc4ce2
feat(auth): persistent login system + C7 session introspection
Human
minor
⚠ breaking
17 days ago
| 1 | #!/usr/bin/env bash |
| 2 | # Verify the safe Muse bridge workflow does not delete local ignored files. |
| 3 | # |
| 4 | # This is a smoke test for the repository-level bridge workflow. It creates a |
| 5 | # throwaway Muse repo, exports into an isolated mirror git checkout, and asserts |
| 6 | # that ignored local state remains outside the bridge's deletion boundary. |
| 7 | |
| 8 | set -euo pipefail |
| 9 | |
| 10 | fail() { |
| 11 | echo "ERROR: $*" >&2 |
| 12 | exit 1 |
| 13 | } |
| 14 | |
| 15 | require_cmd() { |
| 16 | command -v "$1" >/dev/null 2>&1 || fail "Missing required command: $1" |
| 17 | } |
| 18 | |
| 19 | require_cmd git |
| 20 | require_cmd muse |
| 21 | |
| 22 | TMP_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/knowtation-bridge-safety.XXXXXX") |
| 23 | cleanup() { |
| 24 | rm -rf "$TMP_ROOT" |
| 25 | } |
| 26 | trap cleanup EXIT |
| 27 | |
| 28 | SRC="$TMP_ROOT/source" |
| 29 | MIRROR="$SRC/.muse/mirror" |
| 30 | |
| 31 | mkdir -p "$SRC" |
| 32 | cd "$SRC" |
| 33 | |
| 34 | git init -q |
| 35 | git config user.email "[email protected]" |
| 36 | git config user.name "Bridge Safety Test" |
| 37 | |
| 38 | muse init --domain code >/dev/null |
| 39 | |
| 40 | cat > .gitignore <<'EOF' |
| 41 | .muse/ |
| 42 | .env |
| 43 | .env.* |
| 44 | !.env.example |
| 45 | config/local.yaml |
| 46 | config/*-local.* |
| 47 | data/ |
| 48 | *.db |
| 49 | *.sqlite |
| 50 | EOF |
| 51 | |
| 52 | cat > .museignore <<'EOF' |
| 53 | [global] |
| 54 | patterns = [ |
| 55 | ".env", |
| 56 | "config/local.yaml", |
| 57 | "config/*-local.*", |
| 58 | "data/", |
| 59 | "*.db", |
| 60 | "*.sqlite", |
| 61 | ] |
| 62 | |
| 63 | [domain.code] |
| 64 | patterns = [] |
| 65 | EOF |
| 66 | |
| 67 | mkdir -p scripts config data "$MIRROR" |
| 68 | |
| 69 | cat > README.md <<'EOF' |
| 70 | # Bridge safety smoke test |
| 71 | EOF |
| 72 | |
| 73 | cat > .env.example <<'EOF' |
| 74 | EXAMPLE_ONLY=1 |
| 75 | EOF |
| 76 | |
| 77 | cat > scripts/hello.sh <<'EOF' |
| 78 | #!/usr/bin/env bash |
| 79 | echo "hello" |
| 80 | EOF |
| 81 | chmod +x scripts/hello.sh |
| 82 | |
| 83 | cat > .env <<'EOF' |
| 84 | SENTINEL_ONLY=do-not-delete |
| 85 | EOF |
| 86 | cat > config/local.yaml <<'EOF' |
| 87 | sentinel: do-not-delete |
| 88 | EOF |
| 89 | cat > data/local.sqlite <<'EOF' |
| 90 | sentinel-only |
| 91 | EOF |
| 92 | |
| 93 | muse code add README.md .env.example scripts/hello.sh .gitignore .museignore >/dev/null |
| 94 | muse commit -m "test: seed bridge safety fixture" >/dev/null |
| 95 | |
| 96 | git -C "$MIRROR" init -q |
| 97 | git -C "$MIRROR" config user.email "[email protected]" |
| 98 | git -C "$MIRROR" config user.name "Bridge Safety Test" |
| 99 | git -C "$MIRROR" checkout -b muse-mirror >/dev/null 2>&1 |
| 100 | git -C "$MIRROR" commit --allow-empty -m "seed mirror branch" >/dev/null |
| 101 | |
| 102 | muse bridge git-export \ |
| 103 | --git-dir "$MIRROR" \ |
| 104 | --git-branch muse-mirror \ |
| 105 | --git-remote origin \ |
| 106 | --no-push \ |
| 107 | --exclude '.env' \ |
| 108 | --exclude '.env.local' \ |
| 109 | --exclude '.env.*.local' \ |
| 110 | --exclude 'config/local.yaml' \ |
| 111 | --exclude 'config/*-local.*' \ |
| 112 | --exclude 'data/*' \ |
| 113 | --exclude 'data/**' \ |
| 114 | --exclude '*.db' \ |
| 115 | --exclude '*.sqlite' >/dev/null |
| 116 | |
| 117 | [[ -f "$SRC/.env" ]] || fail ".env sentinel was deleted from source repo" |
| 118 | [[ -f "$SRC/config/local.yaml" ]] || fail "config/local.yaml sentinel was deleted from source repo" |
| 119 | [[ -f "$SRC/data/local.sqlite" ]] || fail "data/local.sqlite sentinel was deleted from source repo" |
| 120 | |
| 121 | git -C "$MIRROR" ls-tree -r --name-only HEAD | grep -qx 'scripts/hello.sh' \ |
| 122 | || fail "scripts/hello.sh was not exported to the mirror" |
| 123 | |
| 124 | MODE=$(git -C "$MIRROR" ls-tree HEAD scripts/hello.sh | awk '{print $1}') |
| 125 | [[ "$MODE" == "100755" ]] || fail "scripts/hello.sh mode is $MODE, expected 100755" |
| 126 | |
| 127 | if git -C "$MIRROR" ls-tree -r --name-only HEAD | grep -Eq '^(\.env$|config/local\.yaml$|data/)'; then |
| 128 | fail "local-only sentinel files leaked into the mirror commit" |
| 129 | fi |
| 130 | |
| 131 | echo "PASS: Muse bridge safety smoke test preserved local ignored files and executable mode." |
File History
1 commit
sha256:8d46372e39d2d5a54fd93a8b1c27922fe0d9b22a72197345f1d2c71701cc4ce2
feat(auth): persistent login system + C7 session introspection
Human
minor
⚠
17 days ago