fix(install-e2e): a fresh install has no state.db until the first turn
The session probe returns -1 when the db is unreadable, which is exactly the expected state before the first turn -- so asserting 'before >= 0' failed every leg on a clean install (observed: sessions -1 -> 1, i.e. the turn DID create the row). Treat a negative count as zero and assert only that the turn made it grow.
This commit is contained in:
@@ -58,10 +58,16 @@ user_state_produce() {
|
||||
fail "the installed CLI has no one-shot chat flag; this leg cannot produce a session through the user path"
|
||||
fi
|
||||
after="$(_user_state_db_sessions)"
|
||||
if [ "${before:-0}" -ge 0 ] && [ "${after:-0}" -gt "${before:-0}" ]; then
|
||||
ok "a real turn created a session (state.db sessions $before -> $after)"
|
||||
# A fresh install has NO state.db until the first turn, so the probe's -1
|
||||
# ("no readable db yet") is the expected starting point, not a failure. Only
|
||||
# growth matters: the turn must have created rows.
|
||||
local before_n after_n
|
||||
if [ "${before:-0}" -lt 0 ]; then before_n=0; else before_n="${before:-0}"; fi
|
||||
if [ "${after:-0}" -lt 0 ]; then after_n=0; else after_n="${after:-0}"; fi
|
||||
if [ "$after_n" -gt "$before_n" ]; then
|
||||
ok "a real turn created a session (state.db sessions $before_n -> $after_n)"
|
||||
else
|
||||
fail "the chat turn produced no session row (state.db sessions $before -> $after)"
|
||||
fail "the chat turn produced no session row (state.db sessions $before_n -> $after_n)"
|
||||
fi
|
||||
|
||||
# --- a pooled credential -------------------------------------------------
|
||||
|
||||
@@ -977,7 +977,11 @@ function Invoke-UserStateActions {
|
||||
Write-LogGroup 'first real chat turn' $log
|
||||
if ($chatExit -ne 0) { throw "the first chat turn failed (exit $chatExit); see $log" }
|
||||
$after = Get-UserStateSessionCount
|
||||
if (-not ($before -ge 0 -and $after -gt $before)) {
|
||||
# A fresh install has no state.db until the first turn: -1 means "no
|
||||
# readable db yet", the expected starting point, not a failure.
|
||||
if ($before -lt 0) { $before = 0 }
|
||||
if ($after -lt 0) { $after = 0 }
|
||||
if (-not ($after -gt $before)) {
|
||||
throw "the chat turn produced no session row (state.db sessions $before -> $after)"
|
||||
}
|
||||
Write-Host " a real turn created a session (state.db sessions $before -> $after)"
|
||||
|
||||
Reference in New Issue
Block a user