refactor(agents): move kb_persistence middleware into main_agent (owner)

The KB-persistence impl lived in shared/middleware/ but no subagent uses it --
consumers are the main_agent builder and the boundary event loop. Colocate with
its owner using the folder-per-middleware shape; __init__ re-exports the public
surface. Tests that reached module internals now alias the .middleware submodule.

  main_agent/middleware/kb_persistence.py -> kb_persistence/builder.py
  shared/middleware/kb_persistence.py     -> kb_persistence/middleware.py
This commit is contained in:
CREDO23 2026-06-05 14:11:55 +02:00
parent a7a642fedc
commit 0081b627e9
6 changed files with 19 additions and 5 deletions

View file

@ -0,0 +1,13 @@
"""End-of-turn KB persistence middleware (main-agent only)."""
from .builder import build_kb_persistence_mw
from .middleware import (
KnowledgeBasePersistenceMiddleware,
commit_staged_filesystem_state,
)
__all__ = [
"KnowledgeBasePersistenceMiddleware",
"build_kb_persistence_mw",
"commit_staged_filesystem_state",
]

View file

@ -3,7 +3,8 @@
from __future__ import annotations
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
from app.agents.chat.multi_agent_chat.shared.middleware.kb_persistence import (
from .middleware import (
KnowledgeBasePersistenceMiddleware,
)

View file

@ -11,10 +11,10 @@ from __future__ import annotations
from collections.abc import AsyncGenerator
from typing import Any
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
from app.agents.chat.multi_agent_chat.shared.middleware.kb_persistence import (
from app.agents.chat.multi_agent_chat.main_agent.middleware.kb_persistence import (
commit_staged_filesystem_state,
)
from app.agents.chat.multi_agent_chat.shared.filesystem_selection import FilesystemMode
from app.services.new_streaming_service import VercelStreamingService
from app.tasks.chat.streaming.contract.file_contract import (
contract_enforcement_active,

View file

@ -15,7 +15,7 @@ from unittest.mock import AsyncMock
import numpy as np
import pytest
from app.agents.chat.multi_agent_chat.shared.middleware import kb_persistence
from app.agents.chat.multi_agent_chat.main_agent.middleware.kb_persistence import middleware as kb_persistence
from app.db import Document

View file

@ -21,7 +21,7 @@ from unittest.mock import AsyncMock, MagicMock
import pytest
from app.agents.chat.multi_agent_chat.shared.middleware import kb_persistence
from app.agents.chat.multi_agent_chat.main_agent.middleware.kb_persistence import middleware as kb_persistence
pytestmark = pytest.mark.unit