- Add internal reuse_last_evidence tool for continuing existing topic without repeated retrieval - Expand OpenAI output capacity to 120s / 5,760,000 bytes and add delivery fairness - Coalesce adjacent user ASR transcript deltas to prevent client control queue overflow - Add server-side OPENAI_REALTIME_SPEED configuration and update style to v4 - Add extensive unit and integration regressions for evidence reuse, capacity, and fairness
52 lines
2.3 KiB
Python
52 lines
2.3 KiB
Python
"""Both outbound authority fences use real, current PostgreSQL authority."""
|
|
import pytest
|
|
from sqlalchemy import text
|
|
|
|
from app.modules.knowledge.evidence import SearchExecution
|
|
from tests.integration.test_phase2_postgres import seeded_env, reserve
|
|
|
|
pytestmark = pytest.mark.postgres
|
|
|
|
|
|
@pytest.mark.parametrize('stale', ['session', 'turn'])
|
|
def test_joint_stream_check_rejects_either_stale_capture(seeded_env, stale):
|
|
e = seeded_env
|
|
_, sid = reserve(e)
|
|
session, turn = SearchExecution(e.actor), SearchExecution(e.actor)
|
|
e.lifecycle.validate_stream(e.user, sid, turn, session_execution=session)
|
|
# Change actual actor authority without notifying the in-memory registry.
|
|
with e.engine.begin() as conn:
|
|
conn.execute(text("UPDATE users SET role='user' WHERE id=:id"), {'id': e.actor})
|
|
fresh = SearchExecution(e.actor)
|
|
e.lifecycle.validate_stream(e.user, sid, fresh)
|
|
if stale == 'session':
|
|
turn = fresh
|
|
else:
|
|
session = fresh
|
|
with pytest.raises(ValueError, match='CONTEXT_REVOKED'):
|
|
e.lifecycle.validate_stream(e.user, sid, turn, session_execution=session)
|
|
|
|
|
|
@pytest.mark.parametrize('change,code', [
|
|
('logout', 'SESSION_REVOKED'), ('disable', 'ACCOUNT_DISABLED'),
|
|
('epoch', 'CONVERSATION_STALE'), ('close', 'LIVE_SESSION_UNUSABLE'),
|
|
])
|
|
def test_joint_stream_check_preserves_current_authority_gates(seeded_env, change, code):
|
|
e = seeded_env
|
|
_, sid = reserve(e)
|
|
session, turn = SearchExecution(e.actor), SearchExecution(e.actor)
|
|
e.lifecycle.validate_stream(e.user, sid, turn, session_execution=session)
|
|
with e.engine.begin() as conn:
|
|
if change == 'logout':
|
|
conn.execute(text('UPDATE auth_sessions SET revoked_at=now() WHERE id=:id'),
|
|
{'id': e.user.auth_session_id})
|
|
elif change == 'disable':
|
|
conn.execute(text('UPDATE users SET is_enabled=false WHERE id=:id'), {'id': e.actor})
|
|
elif change == 'epoch':
|
|
conn.execute(text('UPDATE organization_settings SET access_epoch=access_epoch+1 WHERE organization_id=:id'),
|
|
{'id': e.org})
|
|
if change == 'close':
|
|
e.lifecycle.finish_session(e.user, sid)
|
|
with pytest.raises(ValueError, match=code):
|
|
e.lifecycle.validate_stream(e.user, sid, turn, session_execution=session)
|