feat: adopt local SQLite engineering memory and quality gates

This commit is contained in:
2026-11-22 14:39:00 +00:00
parent f5d5db73c2
commit 218c060b94
228 changed files with 28728 additions and 1161 deletions
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""Validate a complete candidate before activation, using only disposable project data."""
import hashlib
import json
from pathlib import Path
import subprocess
import sys
import tempfile
package = Path(sys.argv[1]).resolve()
manifest = json.loads((package / "aie-package.json").read_text())
if manifest.get("schemaVersion") != 1 or manifest.get("protocolVersion") != 4:
raise SystemExit("Unsupported native package manifest")
expected = manifest["files"]
actual = set()
for path in package.rglob("*"):
if path.is_symlink():
raise SystemExit("Package components must be regular files, not symlinks")
if path.is_file() and path.name != "aie-package.json":
relative = str(path.relative_to(package)); actual.add(relative)
if hashlib.sha256(path.read_bytes()).hexdigest() != expected.get(relative):
raise SystemExit("Package integrity mismatch: " + relative)
aie_name = "ai-engineering.exe" if "ai-engineering.exe" in actual else "ai-engineering"
sqlite_name = "sqlite3.exe" if "sqlite3.exe" in actual else "sqlite3"
if actual != set(expected) or not {aie_name, sqlite_name}.issubset(actual):
raise SystemExit("Incomplete package components")
if not any(name.startswith("libsqlitejdbc.") or name == "sqlitejdbc.dll" for name in actual):
raise SystemExit("Missing companion SQLite JDBC library")
aie, sqlite = package / aie_name, package / sqlite_name
if subprocess.check_output([str(aie), "--version"], text=True).strip() != "ai-engineering " + manifest["aieVersion"]:
raise SystemExit("AIE package version mismatch")
if subprocess.check_output([str(sqlite), "--version"], text=True).split()[0] != manifest["sqliteVersion"]:
raise SystemExit("SQLite package version mismatch")
with tempfile.TemporaryDirectory(prefix="aie-package-check-") as temporary:
root = Path(temporary)
subprocess.run([str(aie), "init", "--name", "Disposable package verification"], cwd=root,
check=True, stdout=subprocess.DEVNULL)
database = root / ".ai-engineering/aie.db"
if not database.is_file():
raise SystemExit("Native AIE did not create its disposable database")
result = subprocess.check_output([str(sqlite), "-readonly", str(database), "PRAGMA quick_check;"], text=True).strip()
if result != "ok":
raise SystemExit("Packaged SQLite cannot read the native AIE database")
print("Native package verified:", package)