mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(optimal): make IndexJournalEntryParams.entry_id required
Task 22 added a runtime ValueError when entry_id is None, but the dataclass still typed it Optional. Contract-vs-runtime split — callers get no IDE/mypy hint about the required field. Tighten the type to UUID (required) and remove the misleading "can be None for system events" docstring note. Lifecycle events already use their synthetic uuid5 path, so no real caller is broken.
This commit is contained in:
@@ -75,18 +75,25 @@ async def test_index_journal_entry_raises_when_entry_id_is_none() -> None:
|
||||
"""``entry_id=None`` must raise — the silent fallback hid an upstream
|
||||
bug where the entry row hadn't been flushed before indexing, producing
|
||||
``roboco://journals/None`` doc-sources in the RAG store.
|
||||
|
||||
``entry_id`` is typed ``UUID`` (required); a real caller would have to
|
||||
bypass the dataclass type contract for this to fire (e.g. via
|
||||
``cast(UUID, None)``). We simulate that with a ``SimpleNamespace`` so
|
||||
we don't have to reach inside a frozen-style dataclass to clobber a
|
||||
field — same pattern used by the conversation test below.
|
||||
"""
|
||||
svc = _service_with_stub_plugin()
|
||||
params = IndexJournalEntryParams(
|
||||
fake_params = SimpleNamespace(
|
||||
content="some reflection",
|
||||
entry_type="reflect",
|
||||
entry_id=None, # the bug we now reject
|
||||
agent_id=uuid4(),
|
||||
task_id=uuid4(),
|
||||
tags=None,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="entry_id is required"):
|
||||
await svc.index_journal_entry(params)
|
||||
await svc.index_journal_entry(cast("IndexJournalEntryParams", fake_params))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user