Files
chandra/scripts/test.sh
T
Claude 932fca627e
CI / test (push) Successful in 2m6s
Face unlock: a Howdy-style PAM module, shown in the password dialog and set up in Settings
- face/pam_chandra_face.so (`-auth sufficient`): runs `chandra-face compare` as root with a clean
  environment, forwards what it says as PAM_TEXT_INFO / PAM_ERROR_MSG, and maps its exit status
  to success / auth error / unavailable, so the password always still works. Skips remote
  sessions (PAM_RHOST, SSH_CONNECTION), a closed lid and users without faces; refuses a helper
  that isn't root's; kills one that hangs (timeout + 6 s).
- face/chandra-face (Python + OpenCV): YuNet finds the face, SFace embeds it, cosine similarity
  against the enrolled embeddings (threshold 0.42, two matching frames, dark IR warm-up frames
  skipped, optional require_ir). enroll / list / remove / clear / test / status / pam
  enable|disable / fetch-models (sha256-pinned opencv_zoo models). Embeddings only, in
  /var/lib/chandra-face/USER/faces.json (root, 0600); labels in faces.list (0644). Store, config
  and models must be root's and not writable by others. Root commands re-run through run0 (or
  pkexec), so polkit asks first. Settings in /etc/chandra/face.conf.
- `just install-face [--pam]`, `just uninstall-face [--purge]` (face/install.py; uninstall takes
  the module out of every PAM service first). `pam enable` inserts before the first auth or
  @include line (Debian's sudo has only @include common-auth), keeping a .bak.
- Password dialog: a face row ("Looking for your face…" with a sweeping ring, "Face
  recognized", or why not, "Type your password instead"); typing and Enter during the scan go in
  when PAM asks for the password. Howdy's pam_howdy.so messages are understood too.
- Settings > Session > Face unlock: "Use my face for passwords" (polkit-1 + sudo), the enrolled
  faces (Remove takes a second click), "Add a face…", and the tool's progress. New `face-unlock`
  capability: tables 24 (status) and 25 (faces), request 44, in the wasmer/wasmtime stub, the Rust
  host, the MoonBit wasmhost and chandra:host/plasmoids. compositor/shell/face.mbt runs the tool
  on a socket so the compositor never waits.
- Tests: face/test_face.py (fake camera of PGM frames + fake recognizer; --pam builds the module
  and runs it through pamtester), dialog states and message parsing (polkit_test), the dialog via
  a mock helper (auth_test, shots 14/15), Settings against a fake chandra-face (face_test).
  scripts/test.sh runs them (compositor/polkit was missing from its native list), CI installs
  libpam0g-dev + pamtester. Also regenerated two stale desktop-module bindings (doc comments).
- docs/face-unlock.md, including the limits of 2D face recognition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
2026-11-26 01:19:29 +00:00

57 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Full verification, identical to CI:
# WIT parses -> bindings are fresh -> moon check/test (pure logic) ->
# build all components -> conformance -> host integration tests.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
export PATH="$ROOT/.tools/bin:$HOME/.moon/bin:$PATH"
step() { printf '\n== %s\n' "$*"; }
step "bindings are in sync with wit/"
scripts/gen-bindings.sh --check
step "moon check"
moon check
step "moon test (pure logic, wasm target)"
# compositor/* is left out: on the wasm target those packages import chandra:host/* (the native
# host supplies them), so a plain wasm test runner can't instantiate them. They run natively below.
mapfile -t wasm_pkgs < <(find . -name moon.pkg -not -path './.mooncakes/*' -not -path './_build/*' \
-not -path './.tools/*' -not -path './compositor/*' -not -path '*/node_modules/*' -printf '%h\n' | sed 's#^\./##' | sort)
moon test "${wasm_pkgs[@]}"
step "build components"
scripts/build.sh
step "build wm & decoration components"
scripts/build-wm.sh
step "build wasi-gfx GUI loader component"
scripts/build-gfx.sh
if command -v wasmtime >/dev/null; then
step "wasmtime accepts every component (compile only; hosts supply the imports)"
for f in build/components/*.wasm; do
wasmtime compile "$f" -o "$(mktemp -u).cwasm" >/dev/null && echo " ok $(basename "$f")"
done
fi
step "face unlock (chandra-face with a fake camera; the PAM module through pamtester as root)"
python3 face/test_face.py --pam
step "host integration tests (jco + Node)"
(cd host && npm test)
step "pure-MoonBit native Wayland compositor + wasi-gfx + e2e tests (compositor/)"
# The native compositor links the wasmer C API (scripts/setup-toolchain.sh puts it in .tools/wasmer).
WASMER="$ROOT/.tools/wasmer"
if [ -d "$WASMER/lib" ]; then
export C_INCLUDE_PATH="$WASMER/include${C_INCLUDE_PATH:+:$C_INCLUDE_PATH}"
export LIBRARY_PATH="$WASMER/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
export LD_LIBRARY_PATH="$WASMER/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
XDG_CONFIG_HOME="$(mktemp -d)" CHANDRA_TEST_CONFIG=1 \
moon test --target native --warn-list -a compositor/renderer compositor/gfx compositor/wasm \
compositor/network compositor/portal compositor/polkit compositor/host
moon build --target native --warn-list -a compositor/bin