Adopted recommendation (B): make owner authority a hard guarantee instead of the non-breaking opt-in. A mutating op now requires a stamped HELLO identity; anonymous writes are rejected. seal/open (destructive writes) are gated the same way, and seal stamps the owner onto the encrypted record. Design / non-breaking bridge: - Session gains enforce_owner: bool (default false) so library/REPL/unit tests stay permissive — the 26 prior tests + 3 Task-6 tests are unchanged. - owner_violation() gains require_identity: the (false) path keeps legacy behaviour; the (true) path rejects no-identity mutating ops. - The daemon flips enforce_owner=true on every connection (both HELLO and no-HELLO branches), implementing the default --require-identity policy. - Added --allow-anonymous escape hatch so legacy cubec/stress.sh (which send no HELLO) keep working; stress.sh now passes --allow-anonymous. - Session::set_enforce_owner() accessor so the daemon (separate bin) can set the private field. Verification: - ./check quick: EXIT=0, fmt+clippy clean, 28 cubesys lib tests (added enforce_owner_requires_identity, seal_open_respect_owner). - Ad-hoc daemon verifier (LE framing) against the rebuilt cube-server: anonymous prog/del rejected, HELLO'd owner first-claim + self-overwrite allowed, cross-owner overwrite rejected. ALL PASS. Note: seal's demo key-cell crypto path (KeyCellMissing on the synthetic key material) is a pre-existing quirk unrelated to this change; the gate fires before crypto, so the test verifies the gate, not the crypto.
68 lines
2.8 KiB
Bash
Executable File
68 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Sustained stress stage for CUBELinux-2 (invoked by `./check stress`).
|
|
#
|
|
# Builds cube-server + cubec from THIS workspace tree, spins a fresh daemon on a
|
|
# throwaway socket + store, then drives it hard for STRESS_SECONDS (default 150)
|
|
# with real prog/run traffic while sampling the per-command latency + per-C
|
|
# namespace telemetry. This exercises the new cubesys `stats` path under load.
|
|
#
|
|
# It deliberately does NOT touch the production daemon (real socket/store in
|
|
# /home/luulu/.cubelinux) so it is safe to run any time. Numbers are
|
|
# informational; the stage passes iff the gate passed and the daemon survives.
|
|
set -uo pipefail
|
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$REPO"
|
|
export PATH="$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
|
|
command -v cargo >/dev/null || { echo "cargo not found" >&2; exit 127; }
|
|
|
|
JOBS="${JOBS:-4}"
|
|
SECS="${STRESS_SECONDS:-150}"
|
|
|
|
echo "building cube-server + cubec from tree ($REPO) ..."
|
|
cargo build -p cubesys --release --bins --jobs "$JOBS" >/dev/null 2>&1 || {
|
|
echo "BUILD FAILED (cubesys bins)"; exit 1
|
|
}
|
|
SRV="$REPO/target/release/cube-server"
|
|
CLI="$REPO/target/release/cubec"
|
|
[ -x "$SRV" ] && [ -x "$CLI" ] || { echo "binaries missing after build"; exit 1; }
|
|
|
|
TMPD="$(mktemp -d /tmp/cube-stress.XXXXXX)"
|
|
SOCK="$TMPD/cube.sock"
|
|
STORE="$TMPD/store.json"
|
|
trap 'kill $DPID 2>/dev/null; wait $DPID 2>/dev/null; rm -rf "$TMPD"' EXIT
|
|
|
|
echo "starting stress daemon on $SOCK ..."
|
|
# Legacy clients (cubec in this script) send no HELLO, so run the daemon in
|
|
# anonymous-allowed mode; owner enforcement is exercised by the unit/ad-hoc
|
|
# verifiers, not the stress harness.
|
|
"$SRV" --socket "$SOCK" --store "$STORE" --allow-anonymous >"$TMPD/daemon.log" 2>&1 &
|
|
DPID=$!
|
|
# wait for socket (max ~15s)
|
|
for i in $(seq 1 15); do [ -S "$SOCK" ] && break; sleep 1; done
|
|
[ -S "$SOCK" ] || { echo "daemon failed to start (see $TMPD/daemon.log)"; kill $DPID 2>/dev/null; exit 1; }
|
|
|
|
START=$(date +%s)
|
|
END=$((START + SECS))
|
|
PAIRS=0
|
|
SAMPLE_EVERY=25 # sample stats every 25 pairs (~ once a second at load)
|
|
while [ "$(date +%s)" -lt "$END" ]; do
|
|
X=$((PAIRS % 256))
|
|
"$CLI" --socket "$SOCK" "prog /c077/z001/y001/x$X const $((PAIRS % 97)) halt" >/dev/null 2>&1
|
|
"$CLI" --socket "$SOCK" "run /c077/z001/y001/x$X" >/dev/null 2>&1
|
|
PAIRS=$((PAIRS + 1))
|
|
if [ "$((PAIRS % SAMPLE_EVERY))" -eq 0 ]; then
|
|
echo "--- [$(date -u +%H:%M:%S)] stress sample $((PAIRS / SAMPLE_EVERY)) (pairs=$PAIRS) ---"
|
|
"$CLI" --socket "$SOCK" "stats" || true
|
|
fi
|
|
done
|
|
|
|
# final health snapshot
|
|
echo "--- final stats (pairs driven: $PAIRS over ~${SECS}s) ---"
|
|
"$CLI" --socket "$SOCK" "stats" || true
|
|
|
|
ELAPSED=$(($(date +%s) - START))
|
|
if [ "$ELAPSED" -lt 1 ]; then ELAPSED=1; fi
|
|
echo "stress throughput: ~$((PAIRS / ELAPSED)) prog+run pairs/s (informational)"
|
|
echo "STRESS STAGE OK (daemon alive, $PAIRS pairs driven)"
|
|
exit 0
|