set -euo pipefail
export LC_COLLATE=C
SRV=insuniverse-server; META4=.claude/meta/2026-10-19-admin-rbac-m4; META5=.claude/meta/2026-10-19-admin-rbac-m5; GD=/home/madsc/work/insuniverse-temp/.git/worktrees/admin-rbac; PERM=insuniverse-server/apps/api/src/modules/auth/permission; AC=insuniverse-server/apps/api/src/modules/auth/access-control; M1TAB=.claude/meta/2026-10-19-admin-rbac-m1/route-contract-table.md
# 검사 #7: 세 인증 가드의 공개 표지 조회가 getAllAndOverride 이고 역할 가드가 공개 표지를 존중하며, 프로덕션 코드에 공개 표지 설정이 없다
# 기대: admin · user · user-optional 가드 파일에 getAllAndOverride 가 있고, 핸들러 단독 조회 줄이 없고, roles.guard.ts 가 핸들러 표지 isPublic 만 읽는다 (클래스 표지로는 읽지 않는다), 프로덕션 (시험 제외) 에 SetMetadata('isPublic' 이 0 건이고, 가드 네 곳 밖의 프로덕션 파일에 문자열 isPublic 이 0 건이다 (상수 키 우회 차단, 최종 리뷰 R1)
# 음성: 핸들러 단독 조회 줄을 되돌린 사본에서 두 번째 검사가 rc 1 이다 (구현 뒤 관측 기록). 프로덕션에 표지 한 줄을 붙이면 마지막 검사가 붉다. 상수 키 파일 (const IS_PUBLIC = 'isPublic') 을 넣은 자가시험 디렉터리는 문자열 검사에서 걸린다 (아래 자가시험)
for f in modules/auth/admin/jwt.guard.ts modules/auth/user/jwt.guard.ts modules/auth/user/jwt-optional.guard.ts; do
  test -f "$SRV/apps/api/src/$f"
  grep -q "getAllAndOverride" "$SRV/apps/api/src/$f"
  if grep -q "reflector.get<boolean>('isPublic', context.getHandler())" "$SRV/apps/api/src/$f"; then exit 1; fi
done
RG="$SRV/apps/api/src/modules/auth/admin/roles.guard.ts"
test -f "$RG"
grep -qF "this.reflector.get<boolean>('isPublic', context.getHandler())" "$RG"
if grep -q "'isPublic', context.getClass()" "$RG"; then exit 1; fi
PUB=$(grep -rln "SetMetadata('isPublic'" "$SRV/apps/api/src" --include='*.ts' --exclude='*.spec.ts' || true)
[ -z "$PUB" ]
pub_scan() { grep -rlF "isPublic" "$@" --include='*.ts' --exclude='*.spec.ts' 2>/dev/null | grep -vE '/(admin/jwt|user/jwt|user/jwt-optional|admin/roles)\.guard\.ts$' || true; }
[ -z "$(pub_scan "$SRV/apps/api/src")" ]
mkdir -p "$GD/gatekit-m5-neg-pub"
printf "const IS_PUBLIC = 'isPublic';\n" > "$GD/gatekit-m5-neg-pub/neg.ts"
if [ -z "$(pub_scan "$GD/gatekit-m5-neg-pub")" ]; then echo "음성 자가시험 실패: 상수 키 사본이 문자열 검사를 통과했다" >&2; exit 1; fi
rm -rf "$GD/gatekit-m5-neg-pub"

