ec397f2c65
v0.5 (Live Assist — on-the-job voice companion) milestone complete. 4 phases: P0 (pre-execution, v0.1.10) → P1 (assist core + guardrail, v0.1.11) → P2 (integration + tech-debt + NFR, v0.1.12) → P3 (final review + ship, v0.1.13 = milestone release). 16/16 REQs covered (3 ASSIST + 4 NFR + 9 IDEATE). 4 v0.6 backlog. 469 tests passed, 0 failed. 1 P0 fixed (guardrail processor safety). 8 P1+ flagged for v0.6. 8 v0.4 P1+ tech-debt addressed. G-049 + G-067 grill MUSTs resolved. ESCALATION-01 (PIPEDA) OPEN for human legal review before assist surface go-live. ---ci--- project: praxis phase: 3 milestone: v0.5 status: complete requirements: covered: [REQ-ASSIST-01, REQ-ASSIST-02, REQ-ASSIST-03, REQ-NFR-ASSIST-01, REQ-NFR-ASSIST-02, REQ-NFR-ASSIST-03, REQ-NFR-ASSIST-04, REQ-IDEATE-01, REQ-IDEATE-02, REQ-IDEATE-03, REQ-IDEATE-04, REQ-IDEATE-05, REQ-IDEATE-06, REQ-IDEATE-07, REQ-IDEATE-08, REQ-IDEATE-09] partial: [] ---/ci---
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""Mode-conflict guard — assist vs practice mutual exclusivity (REQ-IDEATE-03, TASK-01-05).
|
|
|
|
D-061 states assist is a separate mode (not concurrent with practice). This
|
|
module enforces mutual exclusivity on the server side: starting an assist shift
|
|
while a practice session is active (or vice versa) raises ModeConflictError.
|
|
|
|
The existing /pipecat/webrtc endpoint (practice) calls enforce_mutual_exclusivity(
|
|
..., 'practice'); the new /api/assist/shift/start endpoint calls it with 'assist'.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from db.store import PraxisStore
|
|
|
|
|
|
class ModeConflictError(Exception):
|
|
"""Raised when a learner tries to start a session of one type while an
|
|
active session of the other type exists (REQ-IDEATE-03)."""
|
|
|
|
|
|
async def enforce_mutual_exclusivity(
|
|
store: PraxisStore, learner_id: str, requested_type: str
|
|
) -> None:
|
|
"""Raise ModeConflictError if the learner has an active session of the
|
|
*other* type.
|
|
|
|
requested_type: 'assist' or 'practice'. Ended sessions don't trigger the
|
|
conflict (only active sessions count — ended_at IS NULL).
|
|
"""
|
|
other_type = "practice" if requested_type == "assist" else "assist"
|
|
active = await store.get_active_session(learner_id, other_type)
|
|
if active is not None:
|
|
if requested_type == "assist":
|
|
raise ModeConflictError(
|
|
"Cannot start assist shift: a practice session is active. "
|
|
"End the practice session first."
|
|
)
|
|
raise ModeConflictError(
|
|
"Cannot start practice session: an assist shift is active. "
|
|
"End the shift first."
|
|
)
|
|
|
|
|
|
__all__ = ["enforce_mutual_exclusivity", "ModeConflictError"] |