|
4 | 4 | set -e |
5 | 5 |
|
6 | 6 | cd "$(dirname "$0")/.." |
| 7 | +export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$(pwd)" |
7 | 8 |
|
8 | 9 | echo "Kernels Smoke Test" |
9 | 10 | echo "==================" |
10 | 11 |
|
11 | 12 | echo "" |
12 | | -echo "[1/5] Checking Python version..." |
| 13 | +echo "[1/7] Checking Python version..." |
13 | 14 | python3 --version |
14 | 15 |
|
15 | 16 | echo "" |
16 | | -echo "[2/5] Running minimal example..." |
| 17 | +echo "[2/7] Running minimal example..." |
17 | 18 | python3 examples/01_minimal_request.py |
18 | 19 |
|
19 | 20 | echo "" |
20 | | -echo "[3/5] Running tool execution example..." |
| 21 | +echo "[3/7] Running tool execution example..." |
21 | 22 | python3 examples/02_tool_execution.py |
22 | 23 |
|
23 | 24 | echo "" |
24 | | -echo "[4/5] Checking CLI help..." |
| 25 | +echo "[4/7] Checking CLI help..." |
25 | 26 | python3 -m kernels --help |
26 | 27 |
|
27 | 28 | echo "" |
28 | | -echo "[5/5] Checking CLI version..." |
| 29 | +echo "[5/7] Checking CLI version..." |
29 | 30 | python3 -m kernels --version |
30 | 31 |
|
| 32 | +echo "" |
| 33 | +echo "[6/7] Exercising thread-safe nonce registry..." |
| 34 | +python3 - <<'PY' |
| 35 | +from implementations.permits_threadsafe import ThreadSafeNonceRegistry |
| 36 | +
|
| 37 | +registry = ThreadSafeNonceRegistry(ttl_ms=100) |
| 38 | +assert registry.check_and_record("n", "iss", "sub", "permit", 2, 1000) |
| 39 | +assert registry.check_and_record("n", "iss", "sub", "permit", 2, 1001) |
| 40 | +assert not registry.check_and_record("n", "iss", "sub", "permit", 2, 1002) |
| 41 | +assert registry.cleanup(1205) == 1 |
| 42 | +print("Nonce registry stats:", registry.stats()) |
| 43 | +PY |
| 44 | + |
| 45 | +echo "" |
| 46 | +echo "[7/7] Exercising SQLite audit storage..." |
| 47 | +python3 - <<'PY' |
| 48 | +from implementations.storage import SQLiteAuditStorage |
| 49 | +
|
| 50 | +entry = { |
| 51 | + "ledger_seq": 1, |
| 52 | + "entry_hash": "h1", |
| 53 | + "prev_hash": "genesis", |
| 54 | + "ts_ms": 1, |
| 55 | + "request_id": "req-1", |
| 56 | + "actor": "smoke", |
| 57 | + "intent": "verify", |
| 58 | + "decision": "allow", |
| 59 | + "state_from": "requested", |
| 60 | + "state_to": "approved", |
| 61 | +} |
| 62 | +
|
| 63 | +storage = SQLiteAuditStorage(".tmp/smoke/audit.db") |
| 64 | +storage.append("kernel-smoke", entry) |
| 65 | +print("Storage health:", storage.health()) |
| 66 | +assert storage.list_entries("kernel-smoke")[0]["request_id"] == "req-1" |
| 67 | +PY |
| 68 | + |
31 | 69 | echo "" |
32 | 70 | echo "==================" |
33 | 71 | echo "Smoke test passed." |
0 commit comments