mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-03 05:45:04 +03:00
A base tinha base-red sistêmica herdada de PRs de outras sessões, bloqueando TODOS os PRs do ciclo (o TIA roda a suíte full em fail-safe p/ diffs hub). 4 Fast Quality Gates: - test-discovery (#4877): live-server-allowlist.test.ts em tests/unit/server/ (não-coletado) + vitest → nunca rodava. Convertido p/ node:test em tests/unit/security/. - any-budget:t11 (#4664): 3 explicit-any em tokenRefresh.ts tipados (sem crescer file-size). - docs-symbols (#4868): rotas inexistentes → /api/system/version e PUT /api/providers/{id} {isActive:false}. - docs-all fabricated-claim (#4868 + #4718): 5 bin/*.sh reais criados (rollback, snapshot-data, restore-data, restore-policies, cold-start-bench) + _ops-common.sh (snapshot VACUUM INTO, guards de confirmação/TTY, testes de contrato); NODE_EXTRA_CA_CERTS (env de runtime Node) na allowlist do checker. 7 testes unit base-red (de features alheias à quota): - oauth-providers-config (#4664): teste alinhado ao provider codebuddy-cn do registry. - antigravity-model-aliases (#4636): maxOutputTokens esperado 32769→16384 (cap intencional). - provider-request-capture #4091 (#4861): exemplo do teste trocado de mcp__ (que #4861 isenta de cloak por causa dos 400s de assimetria de histórico) para um tool de terceiro cloakável — preserva o invariante de #4091 SEM reverter #4861. - combo-error-response: convertido de vitest p/ node:test (era coletado pelo glob node:test e crashava); api/** e server/** removidos do vitest.config (config morta). Build MDX (dast-smoke, #4679): - docs/ops/RELEASE_GREEN.md não tinha frontmatter `title` → fumadocs-mdx rejeitava no webpack compile ("invalid frontmatter: title expected string"), quebrando o next build (e o deploy). Frontmatter title adicionado (único doc do collection sem ele). 17/17 Fast Quality Gates + suíte unit completa (17737 testes, 0 fail) + vitest verdes localmente. Co-authored-by: Diego Rodrigues de Sa e Souza <souzamiriamrodrigues790@gmail.com>
62 lines
2.2 KiB
Bash
Executable File
62 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# bin/snapshot-data.sh — consistent point-in-time snapshot of the OmniRoute data
|
|
# volume (the SQLite store under $DATA_DIR). Used by the data-layer incident
|
|
# runbook (docs/INCIDENT_RESPONSE.md §4.4) before any restore.
|
|
#
|
|
# Output: a directory $DB_BACKUPS_DIR/snapshot_<UTC>[_<label>] holding a
|
|
# `VACUUM INTO` copy of storage.sqlite (consistent even with WAL writers active)
|
|
# plus any sibling *.sqlite files. The snapshot id (the timestamp) is printed on
|
|
# stdout so it can be fed straight to restore-data.sh / restore-policies.sh.
|
|
set -euo pipefail
|
|
SCRIPT_NAME="snapshot-data"
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_ops-common.sh"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: bin/snapshot-data.sh [--label <name>] [--data-dir <path>] [-h|--help]
|
|
|
|
Creates a consistent snapshot of the OmniRoute SQLite data under the backups dir
|
|
and prints the snapshot id (UTC timestamp) on stdout.
|
|
|
|
Env: DATA_DIR (default ~/.omniroute), DB_BACKUPS_DIR (default $DATA_DIR/db_backups).
|
|
EOF
|
|
}
|
|
|
|
LABEL=""
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--label) LABEL="${2:?--label needs a value}"; shift 2 ;;
|
|
--data-dir) ops_set_data_dir "${2:?--data-dir needs a value}"; shift 2 ;;
|
|
-h | --help) usage; exit 0 ;;
|
|
*) ops_die "unknown argument: $1 (see --help)" ;;
|
|
esac
|
|
done
|
|
|
|
[ -f "$OMNIROUTE_SQLITE" ] || ops_die "no storage.sqlite at $OMNIROUTE_SQLITE (set DATA_DIR?)"
|
|
|
|
ts="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
id="${ts}${LABEL:+_$LABEL}"
|
|
dest="$OMNIROUTE_BACKUPS_DIR/snapshot_$id"
|
|
mkdir -p "$dest"
|
|
|
|
if command -v sqlite3 >/dev/null 2>&1; then
|
|
# VACUUM INTO yields a transactionally-consistent copy under WAL.
|
|
sqlite3 "$OMNIROUTE_SQLITE" "VACUUM INTO '$dest/storage.sqlite'"
|
|
else
|
|
ops_log "sqlite3 not found — copying files (stop writers first for a clean copy)"
|
|
cp -a "$OMNIROUTE_SQLITE" "$dest/storage.sqlite"
|
|
for ext in -wal -shm; do
|
|
[ -f "${OMNIROUTE_SQLITE}${ext}" ] && cp -a "${OMNIROUTE_SQLITE}${ext}" "$dest/" || true
|
|
done
|
|
fi
|
|
|
|
# Capture sibling SQLite DBs (analytics, etc.) if present.
|
|
for f in "$OMNIROUTE_DATA_DIR"/*.sqlite; do
|
|
[ -e "$f" ] || continue
|
|
[ "$(basename "$f")" = "storage.sqlite" ] && continue
|
|
cp -a "$f" "$dest/" || true
|
|
done
|
|
|
|
printf '%s\n' "$id"
|
|
ops_log "snapshot created: $dest"
|