File size: 751 Bytes
2e818da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""In-memory journal -> append-only log of student interactions per session.

The Evaluator Agent reads the full journal at session end to score mastery.
All entries are immutable once appended.
"""
from collections import defaultdict
from typing import Dict, List

from app.schemas.journal import JournalEntry


class JournalService:
    def __init__(self) -> None:
        self._store: Dict[str, List[JournalEntry]] = defaultdict(list)

    def append(self, entry: JournalEntry) -> None:
        self._store[entry.project_id].append(entry)

    def get_session(self, project_id: str) -> List[JournalEntry]:
        return list(self._store[project_id])

    def clear_session(self, project_id: str) -> None:
        self._store.pop(project_id, None)