Files
SeedPass/scripts/installer_smoke_unix.sh
thePR0M3TH3AN 03958106e1 Add agent mode, hardened TUI harness, coverage gates, and cross-platform installer smoke CI
This commit delivers four related improvements focused on reliability and automation while preserving existing human/TUI workflows.

1) Agent-first CLI mode (additive)
- Added new `seedpass agent` command group (`src/seedpass/cli/agent.py`) and wired it into CLI root.
- Implemented non-interactive profile bootstrap: `seedpass agent init` with `--seed|--seed-file|--generate-seed` and password env injection (`--password-env`).
- Added policy management commands: `agent policy-show` and `agent policy-set` with allow/deny kind controls.
- Added JSON-based secret retrieval: `seedpass -f <fingerprint> agent get <query> --ttl <sec>` with lease metadata and policy enforcement.
- Kept regular human mode fully available; no behavioral changes to interactive TUI entrypoint.

2) TUI agent harness deepening and stabilization
- Refactored harness into scenario profiles: `core`, `extended`, `stress` with `--scenario` selection.
- Added deterministic seeded stress campaigns: `--stress-cycles`, `--stress-seed`.
- Added scenario-specific required coverage keys and report metadata.
- Added post-condition assertions in extended scenario (archive/restore consistency, lock/unlock retrieval recovery).
- Hardened prompt matching for output variants and fail-fast behavior on non-zero SeedPass exit codes.
- Added harness unit tests for helper logic and control flow.

3) Critical module coverage gate tooling
- Added `scripts/check_critical_coverage.py` to enforce per-module thresholds from coverage JSON and report uncovered functions.
- Added override controls (`--threshold`, `--no-default-thresholds`) and optional JSON result output.
- Integrated coverage JSON generation into CI helper script and optional gate execution via `CRITICAL_COVERAGE_GATE=1`.
- Tuned default thresholds using full-suite baseline and increased strictness:
  - `src/main.py >= 50%`
  - `src/seedpass/core/manager.py >= 60%`
  - `src/seedpass/core/encryption.py >= 80%`
  - `src/seedpass/core/migrations.py >= 90%`
- Added tests for coverage gate parser/analysis logic and targeted manager worker path tests.

4) Installer validation framework for beta/main
- Added cross-platform installer smoke scripts:
  - `scripts/installer_smoke_unix.sh`
  - `scripts/installer_smoke_windows.ps1`
- Added GitHub Actions workflow `.github/workflows/installer-smoke.yml` with:
  - reduced PR matrix
  - full scheduled/manual matrix across OS/branch/mode
  - per-job log capture and artifact uploads for failure triage
- Added installer testing documentation and linked from README.

Additional housekeeping
- Added `.venv/` to `.gitignore`.
- Updated docs for new harness scenarios, seeded stress mode, post-condition metadata, coverage gate usage, and installer testing workflow.
2026-02-23 15:47:59 -05:00

59 lines
1.3 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
BRANCH="${1:-beta}"
MODE="${2:-tui}"
case "$MODE" in
tui|gui|both) ;;
*)
echo "[ERROR] MODE must be one of: tui, gui, both" >&2
exit 2
;;
esac
if ! command -v git >/dev/null 2>&1; then
echo "[ERROR] git is required for installer smoke test" >&2
exit 2
fi
TMP_HOME="$(mktemp -d)"
cleanup() {
rm -rf "$TMP_HOME"
}
trap cleanup EXIT
export HOME="$TMP_HOME"
unset DISPLAY || true
unset WAYLAND_DISPLAY || true
echo "[INFO] Smoke install start: branch=$BRANCH mode=$MODE home=$HOME"
bash scripts/install.sh -b "$BRANCH" -m "$MODE"
LAUNCHER="$HOME/.local/bin/seedpass"
APP_DIR="$HOME/.seedpass/app"
if [[ ! -x "$LAUNCHER" ]]; then
echo "[ERROR] launcher missing: $LAUNCHER" >&2
exit 1
fi
if [[ ! -d "$APP_DIR/.git" ]]; then
echo "[ERROR] install dir missing git checkout: $APP_DIR" >&2
exit 1
fi
actual_branch="$(git -C "$APP_DIR" rev-parse --abbrev-ref HEAD)"
if [[ "$actual_branch" != "$BRANCH" ]]; then
echo "[ERROR] expected branch '$BRANCH', got '$actual_branch'" >&2
exit 1
fi
"$LAUNCHER" --help >/tmp/seedpass-installer-smoke-help.txt
echo "[INFO] Re-running installer to validate idempotence"
bash scripts/install.sh -b "$BRANCH" -m "$MODE"
"$LAUNCHER" --help >/tmp/seedpass-installer-smoke-help-2.txt
echo "[SUCCESS] Installer smoke test passed (branch=$BRANCH mode=$MODE)"