diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 14eee78..d83e63d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -6,11 +6,37 @@ on: branches: [ main ] jobs: - readme: + validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Ensure scaffold files exist + + - name: Ensure required files exist run: | test -f README.md test -f LICENSE + test -f .release-versions.env + test -f sql/schema-model-memory.sql + test -f sql/schema-sae.sql + test -f sql/schema-semantic-cache.sql + test -f sql/schema-manifests.sql + test -f sql/schema-proof-bundles.sql + + - name: Validate SQL schemas + run: bash tests/validate-schemas.sh + + - name: Validate scripts (no akai dependency steps) + run: | + # Run validate-scripts but skip the doctor-deep step (no akai in CI) + DB=$(mktemp /tmp/aurekai-ci-XXXXXX.db) + bash scripts/init-db.sh "$DB" + sqlite3 "$DB" "INSERT INTO manifests (schema_version, name, version, operator_count, raw_json) VALUES ('aurekai.deploy.v1','aurekai','0.8.0-alpha.4',89,'{}');" + bash scripts/manifest-verify.sh "$DB" aurekai 0.8.0-alpha.4 + sqlite3 "$DB" "INSERT INTO sae_dictionaries (artifact_name, artifact_ext, layer_index, size_bytes, sha256) VALUES ('t.aksae','.aksae',0,1,'abc');" + bash scripts/sae-audit.sh "$DB" + sqlite3 "$DB" "INSERT INTO proof_bundles (recipe_name, status, version, schema_version, proof_json) VALUES ('r.json','ok','0.8.0-alpha.4','aurekai.deploy.v1','{\"status\":\"ok\"}');" + bash scripts/proof-bundle-export.sh "$DB" /tmp/pbe-out + bash scripts/semantic-cache-bench.sh "$DB" 100 + sqlite3 "$DB" "INSERT INTO semantic_cache (cache_key, value) VALUES ('k','v');" + sqlite3 "$DB" "INSERT INTO model_memory (artifact_name, artifact_ext) VALUES ('m.akmodel','.akmodel');" + bash scripts/release-gate.sh "$DB" diff --git a/.release-versions.env b/.release-versions.env new file mode 100644 index 0000000..e8f31ad --- /dev/null +++ b/.release-versions.env @@ -0,0 +1,4 @@ +AUREKAI_VERSION=0.8.0-alpha.4 +AKAI_PACKAGE_VERSION=0.8.0-alpha.4 +AUREKAI_MANIFEST_SCHEMA=aurekai.deploy.v1 +HELM_CHART_VERSION=0.8.1 diff --git a/README.md b/README.md index 359d940..56a41dc 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,65 @@ # aurekai-sqlite -Aurekai integration surface for Sqlite. +Aurekai integration surface for SQLite — lightweight, serverless, embedded data-ml storage for model memory, SAE dictionaries, semantic cache, manifests, and proof bundles. -Status: planned -Type: data +Status: active +Type: data-ml + +## Overview + +`aurekai-sqlite` provides DDL schemas and scripts to persist and query Aurekai artifacts using SQLite (`sqlite3`). No server required — everything runs embedded. Works with `akai` CLI, the Python `aurekai` SDK, and any standard SQLite tooling. ## Core Template Set -- doctor-deep -- manifest-verify -- model-memory-pack -- sae-audit -- semantic-cache-bench -- proof-bundle-export -- release-gate +| Template | Description | +|---|---| +| `doctor-deep` | Connectivity check, schema integrity, and `akai doctor --deep` | +| `manifest-verify` | Validate `aurekai.deploy.v1` manifest row in the database | +| `model-memory-pack` | Insert `.akmodel` / `.bfmodel` artifacts into `model_memory` table | +| `sae-audit` | Audit SAE dictionary rows in `sae_dictionaries` table | +| `semantic-cache-bench` | Benchmark semantic cache read/write throughput against SQLite | +| `proof-bundle-export` | Export proof bundle rows to `out/proof-bundle.json` | +| `release-gate` | Verify all artifact tables are populated before publish | + +## Quick Start + +```bash +# 1. Install Aurekai runtime +npm install -g @aurekai/runtime@0.8.0-alpha.4 + +# 2. Init the database +bash scripts/init-db.sh /tmp/aurekai.db + +# 3. Run doctor deep +bash scripts/doctor-deep.sh /tmp/aurekai.db + +# 4. Pack a model memory artifact +bash scripts/model-memory-pack.sh /tmp/aurekai.db path/to/artifact.akmodel + +# 5. Run the release gate +bash scripts/release-gate.sh /tmp/aurekai.db +``` + +## Directory Layout + +``` +sql/ DDL schema files +scripts/ Template scripts (doctor-deep, model-memory-pack, …) +examples/ Sample inputs and usage +tests/ Validation scripts +docs/ Quickstart, schema reference, script reference +``` + +## SQL Schemas + +| File | Tables | +|---|---| +| `sql/schema-model-memory.sql` | `model_memory` | +| `sql/schema-sae.sql` | `sae_dictionaries` | +| `sql/schema-semantic-cache.sql` | `semantic_cache` | +| `sql/schema-manifests.sql` | `manifests` | +| `sql/schema-proof-bundles.sql` | `proof_bundles` | ## Canonical References diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 0000000..30cb68c --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1,73 @@ +# Quickstart + +## 1. Clone the repo + +```bash +git clone https://github.com/aurekai/aurekai-sqlite.git +cd aurekai-sqlite +``` + +## 2. Install Aurekai runtime + +```bash +npm install -g @aurekai/runtime@0.8.0-alpha.4 +``` + +## 3. Initialize the database + +```bash +bash scripts/init-db.sh /path/to/aurekai.db +``` + +This applies all five schemas (`model_memory`, `sae_dictionaries`, `semantic_cache`, `manifests`, `proof_bundles`). + +## 4. Run doctor deep + +```bash +bash scripts/doctor-deep.sh /path/to/aurekai.db +``` + +Verifies all required tables exist, prints row counts, and runs `akai doctor --deep`. + +## 5. Insert a manifest + +```python +import sqlite3, json + +db = sqlite3.connect("/path/to/aurekai.db") +manifest = json.load(open("examples/sample-aurekai.manifest.json")) +db.execute( + """INSERT INTO manifests (schema_version, name, version, operator_count, raw_json) + VALUES (?,?,?,?,?)""", + (manifest["schema_version"], manifest["name"], manifest["version"], + manifest["operator_count"], json.dumps(manifest)) +) +db.commit() +``` + +## 6. Pack a model memory artifact + +```bash +bash scripts/model-memory-pack.sh /path/to/aurekai.db path/to/artifact.akmodel +``` + +## 7. Run the release gate + +```bash +bash scripts/release-gate.sh /path/to/aurekai.db +``` + +Checks that all artifact tables have at least one row and no `proof_bundles` row has `status=fail`. + +## 8. End-to-end example + +```bash +bash examples/sample-db-init.sh +``` + +## 9. Run the test suite + +```bash +bash tests/validate-schemas.sh +bash tests/validate-scripts.sh +``` diff --git a/docs/schema.md b/docs/schema.md new file mode 100644 index 0000000..4949b38 --- /dev/null +++ b/docs/schema.md @@ -0,0 +1,99 @@ +# Schema Reference + +## model_memory + +Stores `.akmodel`, `.bfmodel`, `.akfpqx`, `.bffpqx` artifact metadata and optional binary payload. + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER PK | Auto-increment | +| `artifact_name` | TEXT | File name of the artifact | +| `artifact_ext` | TEXT | `.akmodel` / `.bfmodel` / `.akfpqx` / `.bffpqx` | +| `operator_id` | TEXT | Aurekai operator that produced the artifact | +| `version` | TEXT | Aurekai release version | +| `schema_version` | TEXT | Always `aurekai.deploy.v1` | +| `size_bytes` | INTEGER | File size | +| `sha256` | TEXT | Hex SHA-256 checksum | +| `payload` | BLOB | Raw artifact bytes (optional) | +| `created_at` | TEXT | ISO-8601 UTC | +| `updated_at` | TEXT | ISO-8601 UTC | + +--- + +## sae_dictionaries + +Stores `.aksae` / `.bfsae` Sparse Autoencoder dictionary artifacts. + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER PK | Auto-increment | +| `artifact_name` | TEXT | File name | +| `artifact_ext` | TEXT | `.aksae` / `.bfsae` | +| `operator_id` | TEXT | Producing operator | +| `version` | TEXT | Aurekai release version | +| `schema_version` | TEXT | Always `aurekai.deploy.v1` | +| `layer_index` | INTEGER | Network layer index | +| `feature_count` | INTEGER | Number of learned features | +| `size_bytes` | INTEGER | File size | +| `sha256` | TEXT | Hex SHA-256 checksum | +| `payload` | BLOB | Raw bytes (optional) | +| `created_at` | TEXT | ISO-8601 UTC | +| `updated_at` | TEXT | ISO-8601 UTC | + +--- + +## semantic_cache + +Stores semantic cache key→value pairs with optional embedding blobs. + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER PK | Auto-increment | +| `cache_key` | TEXT UNIQUE | Hash key (e.g. SHA-256 of input) | +| `embedding` | BLOB | Optional embedding vector | +| `value` | TEXT | Cached response | +| `hit_count` | INTEGER | Number of times this entry was served | +| `version` | TEXT | Aurekai release version | +| `expires_at` | TEXT | ISO-8601 UTC expiry (nullable) | +| `created_at` | TEXT | ISO-8601 UTC | +| `updated_at` | TEXT | ISO-8601 UTC | + +--- + +## manifests + +Stores `aurekai.deploy.v1` deploy manifest records. + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER PK | Auto-increment | +| `schema_version` | TEXT | Always `aurekai.deploy.v1` | +| `name` | TEXT | Manifest name (e.g. `aurekai`) | +| `version` | TEXT | Release version | +| `operator_count` | INTEGER | Number of operators in release | +| `runtime_ref` | TEXT | Native runtime git ref | +| `helm_chart_ver` | TEXT | Helm chart version | +| `pypi_ver` | TEXT | PyPI package version | +| `npm_ver` | TEXT | npm package version | +| `jsr_ver` | TEXT | JSR package version | +| `raw_json` | TEXT | Full manifest JSON | +| `created_at` | TEXT | ISO-8601 UTC | + +Unique constraint on `(name, version)`. + +--- + +## proof_bundles + +Stores proof bundle export records from `akai run --sae-audit`. + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER PK | Auto-increment | +| `recipe_name` | TEXT | Recipe file that was run | +| `status` | TEXT | `ok` / `fail` / `partial` | +| `operator_id` | TEXT | Producing operator | +| `version` | TEXT | Aurekai release version | +| `schema_version` | TEXT | Always `aurekai.deploy.v1` | +| `proof_json` | TEXT | Proof bundle JSON payload | +| `exported_at` | TEXT | ISO-8601 UTC | diff --git a/docs/scripts.md b/docs/scripts.md new file mode 100644 index 0000000..0f44413 --- /dev/null +++ b/docs/scripts.md @@ -0,0 +1,101 @@ +# Scripts Reference + +All scripts in `scripts/` accept `` as their first argument. + +--- + +## `init-db.sh` + +``` +bash scripts/init-db.sh +``` + +Applies all five DDL schema files in order. Safe to run on an existing database (uses `CREATE TABLE IF NOT EXISTS`). + +--- + +## `doctor-deep.sh` + +``` +bash scripts/doctor-deep.sh +``` + +1. Verifies the database file exists. +2. Checks all five required tables are present. +3. Prints row counts per table. +4. Runs `akai doctor --deep`. + +Exit 1 on any failure. + +--- + +## `manifest-verify.sh` + +``` +bash scripts/manifest-verify.sh +``` + +Queries `manifests` for a row matching `(name, version, schema_version='aurekai.deploy.v1')`. Prints the matched row and exits 1 if not found. + +--- + +## `model-memory-pack.sh` + +``` +bash scripts/model-memory-pack.sh [operator_id] +``` + +Inserts an `.akmodel`, `.bfmodel`, `.akfpqx`, or `.bffpqx` artifact file into the `model_memory` table, including `size_bytes`, `sha256`, and raw payload bytes via SQLite's `readfile()`. + +--- + +## `sae-audit.sh` + +``` +bash scripts/sae-audit.sh +``` + +Prints total row count, breakdown by extension and operator, and warns if any rows are missing `sha256`. + +--- + +## `semantic-cache-bench.sh` + +``` +bash scripts/semantic-cache-bench.sh [iterations] +``` + +Runs `iterations` (default 1000) write + read operations against `semantic_cache` and prints throughput in ops/s. + +--- + +## `proof-bundle-export.sh` + +``` +bash scripts/proof-bundle-export.sh [output_dir] +``` + +Exports all `proof_bundles` rows to `/proof-bundle.json` (default `out/`). The JSON structure is: + +```json +{ + "status": "ok", + "count": 3, + "bundles": [ ... ] +} +``` + +--- + +## `release-gate.sh` + +``` +bash scripts/release-gate.sh +``` + +Checks: +1. Every table has at least one row. +2. All manifests use `schema_version = 'aurekai.deploy.v1'`. +3. No `proof_bundles` row has `status = 'fail'`. + +Exits 1 if any check fails — suitable as a CI pre-publish gate. diff --git a/examples/sample-akmodel.json b/examples/sample-akmodel.json new file mode 100644 index 0000000..dedd227 --- /dev/null +++ b/examples/sample-akmodel.json @@ -0,0 +1,9 @@ +{ + "name": "my-operator-v1", + "ext": ".akmodel", + "operator_id": "akai_run_operator", + "version": "0.8.0-alpha.4", + "schema_version": "aurekai.deploy.v1", + "size_bytes": 204800, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +} diff --git a/examples/sample-aurekai.manifest.json b/examples/sample-aurekai.manifest.json new file mode 100644 index 0000000..ddcfc6f --- /dev/null +++ b/examples/sample-aurekai.manifest.json @@ -0,0 +1,11 @@ +{ + "schema_version": "aurekai.deploy.v1", + "name": "aurekai", + "version": "0.8.0-alpha.4", + "operator_count": 89, + "runtime_ref": "git:1ba1f19", + "helm_chart_ver": "0.8.1", + "pypi_ver": "0.8.0a3", + "npm_ver": "0.8.0-alpha.4", + "jsr_ver": "0.8.0-alpha.3" +} diff --git a/examples/sample-db-init.sh b/examples/sample-db-init.sh new file mode 100644 index 0000000..ac68c4d --- /dev/null +++ b/examples/sample-db-init.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# sample-db-init.sh — End-to-end example: init DB, insert sample manifest, run release gate. +# This is a demo only — artifacts are synthetic. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$SCRIPT_DIR/.." +DB="/tmp/aurekai-sample.db" + +echo "=== aurekai-sqlite sample walkthrough ===" +echo "" + +# 1. Init +echo "Step 1: Initialise database" +bash "$REPO_ROOT/scripts/init-db.sh" "$DB" +echo "" + +# 2. Insert a manifest +echo "Step 2: Insert sample manifest" +MANIFEST=$(cat "$REPO_ROOT/examples/sample-aurekai.manifest.json") +sqlite3 "$DB" < +set -euo pipefail + +DB="${1:?Usage: doctor-deep.sh }" +REQUIRED_TABLES=(model_memory sae_dictionaries semantic_cache manifests proof_bundles) + +echo "[doctor-deep] Checking SQLite file: $DB" +if [ ! -f "$DB" ]; then + echo "[doctor-deep] ERROR: database file not found: $DB" >&2 + exit 1 +fi + +echo "[doctor-deep] Verifying required tables..." +for tbl in "${REQUIRED_TABLES[@]}"; do + count=$(sqlite3 "$DB" "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='$tbl';") + if [ "$count" -ne 1 ]; then + echo "[doctor-deep] MISSING table: $tbl" >&2 + exit 1 + fi + echo " OK: $tbl" +done + +echo "[doctor-deep] Row counts:" +for tbl in "${REQUIRED_TABLES[@]}"; do + rows=$(sqlite3 "$DB" "SELECT count(*) FROM $tbl;") + echo " $tbl: $rows rows" +done + +echo "[doctor-deep] Running akai doctor --deep ..." +akai doctor --deep + +echo "[doctor-deep] PASS" diff --git a/scripts/init-db.sh b/scripts/init-db.sh new file mode 100644 index 0000000..9adfc5a --- /dev/null +++ b/scripts/init-db.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# init-db.sh — Initialize an Aurekai SQLite database with all schemas. +# Usage: bash scripts/init-db.sh +set -euo pipefail + +DB="${1:?Usage: init-db.sh }" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SQL_DIR="$SCRIPT_DIR/../sql" + +echo "[aurekai-sqlite] Initializing database: $DB" +for schema in \ + schema-model-memory.sql \ + schema-sae.sql \ + schema-semantic-cache.sql \ + schema-manifests.sql \ + schema-proof-bundles.sql; do + echo " Applying $schema ..." + sqlite3 "$DB" < "$SQL_DIR/$schema" +done + +echo "[aurekai-sqlite] Schema tables created:" +sqlite3 "$DB" ".tables" +echo "[aurekai-sqlite] Done." diff --git a/scripts/manifest-verify.sh b/scripts/manifest-verify.sh new file mode 100644 index 0000000..8d8523e --- /dev/null +++ b/scripts/manifest-verify.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# manifest-verify.sh — Verify an aurekai.deploy.v1 manifest is stored in the DB. +# Usage: bash scripts/manifest-verify.sh +set -euo pipefail + +DB="${1:?Usage: manifest-verify.sh }" +MANIFEST_NAME="${2:?manifest name required}" +MANIFEST_VERSION="${3:?manifest version required}" + +echo "[manifest-verify] DB: $DB name: $MANIFEST_NAME version: $MANIFEST_VERSION" + +count=$(sqlite3 "$DB" \ + "SELECT count(*) FROM manifests WHERE name='$MANIFEST_NAME' AND version='$MANIFEST_VERSION' AND schema_version='aurekai.deploy.v1';") + +if [ "$count" -lt 1 ]; then + echo "[manifest-verify] FAIL: manifest not found or schema_version mismatch." >&2 + exit 1 +fi + +echo "[manifest-verify] Found $count row(s)." +sqlite3 "$DB" -header -column \ + "SELECT id, name, version, schema_version, operator_count, created_at FROM manifests WHERE name='$MANIFEST_NAME' AND version='$MANIFEST_VERSION';" +echo "[manifest-verify] PASS" diff --git a/scripts/model-memory-pack.sh b/scripts/model-memory-pack.sh new file mode 100644 index 0000000..6cdc73f --- /dev/null +++ b/scripts/model-memory-pack.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# model-memory-pack.sh — Insert a model memory artifact into SQLite. +# Usage: bash scripts/model-memory-pack.sh [operator_id] +set -euo pipefail + +DB="${1:?Usage: model-memory-pack.sh [operator_id]}" +ARTIFACT="${2:?artifact path required}" +OPERATOR_ID="${3:-}" + +if [ ! -f "$ARTIFACT" ]; then + echo "[model-memory-pack] ERROR: artifact not found: $ARTIFACT" >&2 + exit 1 +fi + +EXT=".${ARTIFACT##*.}" +# Normalise extension with leading dot +case "$EXT" in + .akmodel|.bfmodel|.akfpqx|.bffpqx) ;; + *) echo "[model-memory-pack] ERROR: unsupported extension '$EXT' (expected .akmodel/.bfmodel/.akfpqx/.bffpqx)" >&2; exit 1 ;; +esac + +NAME=$(basename "$ARTIFACT") +SIZE=$(wc -c < "$ARTIFACT" | tr -d ' ') +SHA=$(shasum -a 256 "$ARTIFACT" | awk '{print $1}') + +echo "[model-memory-pack] Packing: $NAME ($SIZE bytes, sha256=$SHA)" + +sqlite3 "$DB" < [output_dir] +set -euo pipefail + +DB="${1:?Usage: proof-bundle-export.sh [output_dir]}" +OUT_DIR="${2:-out}" + +mkdir -p "$OUT_DIR" +EXPORT_FILE="$OUT_DIR/proof-bundle.json" + +echo "[proof-bundle-export] DB: $DB output: $EXPORT_FILE" + +count=$(sqlite3 "$DB" "SELECT count(*) FROM proof_bundles;") +echo "[proof-bundle-export] Rows to export: $count" + +python3 - < +set -euo pipefail + +DB="${1:?Usage: release-gate.sh }" +FAIL=0 + +echo "[release-gate] DB: $DB" +echo "[release-gate] Checking artifact table populations..." + +for tbl in model_memory sae_dictionaries semantic_cache manifests proof_bundles; do + count=$(sqlite3 "$DB" "SELECT count(*) FROM $tbl;" 2>/dev/null || echo 0) + if [ "$count" -gt 0 ]; then + echo " PASS $tbl: $count row(s)" + else + echo " FAIL $tbl: 0 rows — not populated" >&2 + FAIL=1 + fi +done + +echo "[release-gate] Checking manifest schema version..." +bad=$(sqlite3 "$DB" "SELECT count(*) FROM manifests WHERE schema_version != 'aurekai.deploy.v1';" 2>/dev/null || echo 0) +if [ "$bad" -gt 0 ]; then + echo " FAIL $bad manifest(s) have wrong schema_version" >&2 + FAIL=1 +else + echo " PASS All manifests use aurekai.deploy.v1" +fi + +echo "[release-gate] Checking proof bundle status..." +failed=$(sqlite3 "$DB" "SELECT count(*) FROM proof_bundles WHERE status='fail';" 2>/dev/null || echo 0) +if [ "$failed" -gt 0 ]; then + echo " FAIL $failed proof bundle(s) have status=fail" >&2 + FAIL=1 +else + echo " PASS No failed proof bundles" +fi + +if [ "$FAIL" -ne 0 ]; then + echo "[release-gate] FAIL — release gate did not pass." >&2 + exit 1 +fi + +echo "[release-gate] PASS — all checks green." diff --git a/scripts/sae-audit.sh b/scripts/sae-audit.sh new file mode 100644 index 0000000..7849437 --- /dev/null +++ b/scripts/sae-audit.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# sae-audit.sh — Audit SAE dictionary rows in the database. +# Usage: bash scripts/sae-audit.sh +set -euo pipefail + +DB="${1:?Usage: sae-audit.sh }" + +echo "[sae-audit] DB: $DB" + +total=$(sqlite3 "$DB" "SELECT count(*) FROM sae_dictionaries;") +echo "[sae-audit] Total SAE rows: $total" + +if [ "$total" -eq 0 ]; then + echo "[sae-audit] WARNING: no SAE dictionary artifacts found in database." +fi + +echo "[sae-audit] Breakdown by extension:" +sqlite3 "$DB" -header -column \ + "SELECT artifact_ext, count(*) as count, sum(size_bytes) as total_bytes FROM sae_dictionaries GROUP BY artifact_ext;" + +echo "[sae-audit] Breakdown by operator:" +sqlite3 "$DB" -header -column \ + "SELECT operator_id, count(*) as count FROM sae_dictionaries GROUP BY operator_id ORDER BY count DESC;" + +echo "[sae-audit] Integrity check (NULL sha256):" +nullsha=$(sqlite3 "$DB" "SELECT count(*) FROM sae_dictionaries WHERE sha256 IS NULL;") +if [ "$nullsha" -gt 0 ]; then + echo "[sae-audit] WARNING: $nullsha row(s) missing sha256 checksum." >&2 +else + echo " All rows have sha256." +fi + +echo "[sae-audit] PASS" diff --git a/scripts/semantic-cache-bench.sh b/scripts/semantic-cache-bench.sh new file mode 100644 index 0000000..b36130e --- /dev/null +++ b/scripts/semantic-cache-bench.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# semantic-cache-bench.sh — Benchmark semantic cache read/write throughput against SQLite. +# Usage: bash scripts/semantic-cache-bench.sh [iterations] +set -euo pipefail + +DB="${1:?Usage: semantic-cache-bench.sh [iterations]}" +ITERATIONS="${2:-1000}" + +echo "[semantic-cache-bench] DB: $DB iterations: $ITERATIONS" + +# Seed bench entries +echo "[semantic-cache-bench] Seeding $ITERATIONS cache entries..." +python3 - <&2 + exit 1 + fi + echo " OK: $tbl" +done + +echo "[validate-schemas] PASS — all tables present." diff --git a/tests/validate-scripts.sh b/tests/validate-scripts.sh new file mode 100644 index 0000000..cf062fe --- /dev/null +++ b/tests/validate-scripts.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# validate-scripts.sh — Smoke-test all template scripts against a fresh database. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$SCRIPT_DIR/.." +DB=$(mktemp /tmp/aurekai-validate-XXXXXX.db) +trap 'rm -f "$DB"' EXIT + +echo "[validate-scripts] DB: $DB" + +# Init +bash "$REPO_ROOT/scripts/init-db.sh" "$DB" + +# Manifest insert + verify +sqlite3 "$DB" <&2; exit 1; } + +# Semantic cache bench (small) +bash "$REPO_ROOT/scripts/semantic-cache-bench.sh" "$DB" 50 + +# Release gate — semantic_cache and model_memory are empty so it should warn; +# patch them so gate passes +sqlite3 "$DB" <