Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/rfcs/harness-selection-dsh-pi-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ explicitly does not promise cross-turn DSH session continuity.

Option A shipped, so this section now records the transport rather than a plan.
The steward channel holds the managed host through
`loopx/chat_dsh.py`: each Chat turn starts **one bounded dsh segment** on the
`loopx/chat/dsh.py`: each Chat turn starts **one bounded dsh segment** on the
resolved execution profile, hands it the channel's bounded visible history plus
the current message, and returns the final assistant message. The snapshot the
segment sees is composed by LoopX and the segment's sandbox is pinned read-only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ adapter 已支持;管家通道还需要一个能持有交互会话的传输,
turn 的 DSH 会话连续性。

路线 A 已落地,因此本节现在记录传输本身,而不是一个计划。管家通道通过
`loopx/chat_dsh.py` 持有托管宿主:每个 chat turn 在解析出的执行档位上启动**一次有界
`loopx/chat/dsh.py` 持有托管宿主:每个 chat turn 在解析出的执行档位上启动**一次有界
dsh 片段**,把通道可见的有界历史与当前消息交给它,并返回最终的 assistant 消息。片段
看到的内容由 LoopX 组装,且片段的沙箱通过 `DSH_PERMISSION_MODE` 固定为只读,因此回答
不可能来自通道从未授予的环境写入或 shell 权威。
Expand Down
2 changes: 1 addition & 1 deletion examples/loopx-managed-turn-operator-flow-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT))

from loopx.chat_dsh import DshChatAdapter # noqa: E402
from loopx.chat.dsh import DshChatAdapter # noqa: E402
from loopx.chat_manager import manager_channel_binding # noqa: E402
from loopx.control_plane.operator_provider import ( # noqa: E402
operator_provider_environ,
Expand Down
2 changes: 1 addition & 1 deletion examples/loopx-steward-managed-chat-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
manager_workspace,
open_manager_session,
)
from loopx.chat_dsh import STEWARD_SEGMENT_ENV # noqa: E402
from loopx.chat.dsh import STEWARD_SEGMENT_ENV # noqa: E402
from loopx.chat_runtime import ChatRuntimeController # noqa: E402
from loopx.chat_store import ChatSessionStore # noqa: E402

Expand Down
2 changes: 1 addition & 1 deletion loopx/capabilities/native_chat/antigravity_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ def start_turn_with_attachments(
event_sink: Callable[[str, dict[str, Any]], None] | None = None,
attachments: list[dict[str, Any]] | None = None,
) -> dict[str, Any]:
from ...chat_attachments import normalize_chat_image_attachments
from ...chat.attachments import normalize_chat_image_attachments

normalized = normalize_chat_image_attachments(attachments or [])
media = [
Expand Down
2 changes: 1 addition & 1 deletion loopx/capabilities/native_chat/codex_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ def healthcheck(self) -> bool:
def start_attachment_turn(adapter: Any, session: dict[str, Any], turn: dict[str, Any], message: str,
event_sink: Callable[[str, dict[str, Any]], None], attachments: list[dict[str, Any]]) -> dict[str, Any]:
"""Keep attachment support and recovered source-route checks at the adapter."""
from ...chat_attachments import require_text_document_route
from ...chat.attachments import require_text_document_route
from .antigravity_adapter import AntigravityAdapter
require_text_document_route(session, attachments, origin=str(turn.get("origin") or "web"))
if not isinstance(adapter, (CodexAppServerAdapter, AntigravityAdapter)):
Expand Down
2 changes: 1 addition & 1 deletion loopx/capabilities/native_chat/external_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from datetime import datetime as datetime, timezone as timezone
from typing import Any

from ...chat_attachments import normalize_chat_image_attachments
from ...chat.attachments import normalize_chat_image_attachments

from ...chat_ingress import (
STEWARD_BINDING_ADOPTION_PENDING as STEWARD_BINDING_ADOPTION_PENDING,
Expand Down
6 changes: 3 additions & 3 deletions loopx/capabilities/native_chat/file_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def reply_image_workspace(session: dict[str, Any], turn: dict[str, Any]) -> Path


def _check_reply_image(data: bytes, mime: str) -> None:
from ...chat_attachments import CHAT_IMAGE_MAX_BYTES
from ...chat.attachments import CHAT_IMAGE_MAX_BYTES

if not data or len(data) > CHAT_IMAGE_MAX_BYTES:
raise ValueError("reply image is empty or exceeds its size bound")
Expand Down Expand Up @@ -539,7 +539,7 @@ def read_reply_image(workspace: Path, turn_id: str, name: str) -> tuple[str, byt

def capture_reply_image_plan(workspace: Path, turn_id: str, targets: list[str]) -> list[str | dict[str, Any] | None]:
"""Pin exact local bytes without keeping host paths in Chat responses."""
from ...chat_attachments import CHAT_IMAGE_MAX_COUNT, CHAT_IMAGE_MAX_TOTAL_BYTES
from ...chat.attachments import CHAT_IMAGE_MAX_COUNT, CHAT_IMAGE_MAX_TOTAL_BYTES

if all(target.startswith("https://") for target in targets):
return [] # The original remote-image path remains authoritative.
Expand Down Expand Up @@ -585,7 +585,7 @@ def __init__(

def _preparation_image_identity(value: Any) -> dict[str, Any] | None:
"""Fingerprint already normalized Core images without exporting their bytes."""
from ...chat_attachments import normalize_chat_image_attachments
from ...chat.attachments import normalize_chat_image_attachments

if not isinstance(value, list) or not value:
return None
Expand Down
2 changes: 1 addition & 1 deletion loopx/capabilities/native_chat/queued_admission.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any

from ...chat_attachments import require_text_document_route
from ...chat.attachments import require_text_document_route
from ...attached_session import enqueue_attached_agent_turn
from ...chat_store import CHAT_SESSION_MODE_ATTACHED
from ...control_plane.collaboration import conversation_scope
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions loopx/chat_dsh.py → loopx/chat/dsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
from typing import Any
import uuid

from .chat import _turn_prompt, parse_agent_response
from .chat_agent import CodexChatAgentError, CodexChatTimeoutError
from .control_plane.turn_driver.host_binding import dsh_output_token_budget
from .dsh_goal_mode.turn_host_adapter import (
from ..chat import _turn_prompt, parse_agent_response
from ..chat_agent import CodexChatAgentError, CodexChatTimeoutError
from ..control_plane.turn_driver.host_binding import dsh_output_token_budget
from ..dsh_goal_mode.turn_host_adapter import (
normalize_runner_outcome,
resolve_dsh_home,
run_dsh_turn,
Expand Down
2 changes: 1 addition & 1 deletion loopx/chat/endpoint_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pathlib import Path
from typing import Any

from ..chat_dsh import STEWARD_SEGMENT_ENV
from .dsh import STEWARD_SEGMENT_ENV
from ..control_plane.operator_provider import operator_provider_environ
from ..control_plane.turn_driver.host_binding import (
MANAGED_TURN_HOST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pathlib import Path
from typing import Protocol

from .control_plane.operator_provider import (
from ..control_plane.operator_provider import (
PROVIDER_KEY_FIELD,
BASE_URL_FIELD,
operator_provider_projection,
Expand Down
2 changes: 1 addition & 1 deletion loopx/chat/result_files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib.parse import quote, unquote

from ..capabilities.manager_context.roundtrip import read_chat_return_file
from ..chat_attachments import CHAT_IMAGE_MAX_BYTES, CHAT_IMAGE_TYPES
from .attachments import CHAT_IMAGE_MAX_BYTES, CHAT_IMAGE_TYPES
from ..control_plane.content_digest import BARE_SHA256_PATTERN
from ..control_plane.effect_runtime import effect_runtime_request_scope

Expand Down
2 changes: 1 addition & 1 deletion loopx/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ def send(
reply_image_directory=image_dir,
)
turn_input: list[dict[str, Any]] = [{"type": "text", "text": text}]
from .chat_attachments import native_attachment_inputs
from .chat.attachments import native_attachment_inputs
turn_input.extend(native_attachment_inputs(attachments))
# A running app-server is not permission for a new native Turn. Hold
# the caller's fence through its write, then release before waiting for
Expand Down
2 changes: 1 addition & 1 deletion loopx/chat_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def create_queued_turn(
from .chat_store import _opaque_id, _atomic_write_json, utc_now, CHAT_TURN_SCHEMA_VERSION

client_id = _opaque_id(client_turn_id, field="client_turn_id")
from .chat_attachments import normalize_chat_attachments, validate_chat_turn_envelope
from .chat.attachments import normalize_chat_attachments, validate_chat_turn_envelope
normalized_attachments = normalize_chat_attachments(attachments) or None
if normalized_attachments:
validate_chat_turn_envelope({"message": message, "attachments": normalized_attachments})
Expand Down
4 changes: 2 additions & 2 deletions loopx/chat_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
parse_native_goal_command,
validate_goal_chat,
)
from .chat_dsh import DshChatAdapter as DshChatAdapter
from .chat.dsh import DshChatAdapter as DshChatAdapter
from .chat.endpoint_catalog import builtin_chat_endpoints
from .chat_endpoints import AgentEndpointRegistry
from .control_plane.chat_turn_acceptance import managed_turn_recovery_allowed
Expand Down Expand Up @@ -420,7 +420,7 @@ def submit_turn(
session = self.store.load_session(session_id)
if session is None:
raise KeyError("chat session was not found")
from .chat_attachments import require_text_document_route
from .chat.attachments import require_text_document_route
require_text_document_route(session, attachments)
if session.get("steward_context") is not None:
raise ValueError("bound steward Chat requires its external source admission")
Expand Down
2 changes: 1 addition & 1 deletion loopx/chat_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .chat import TodoReviewPreviewConflict, redact_local_paths
from .chat_agent import CodexChatAgentError
from .capabilities.native_chat.project_context import ChatProjectContexts
from .chat_attachments import (
from .chat.attachments import (
CHAT_JSON_MAX_BYTES,
CHAT_TURN_MAX_BODY_BYTES,
normalize_local_chat_attachments,
Expand Down
2 changes: 1 addition & 1 deletion loopx/extensions/lark/private_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ...capabilities.native_chat.file_discovery import (
FileChatDiscovery, optional_file_fingerprint, reply_image_workspace,
)
from ...chat_attachments import CHAT_IMAGE_MAX_COUNT
from ...chat.attachments import CHAT_IMAGE_MAX_COUNT
from ...chat_store import TERMINAL_TURN_STATES, _atomic_write_json, _read_json
from ...control_plane.collaboration import conversation_reply_context
from ...control_plane.effect_runtime import effect_runtime_request_scope
Expand Down
2 changes: 1 addition & 1 deletion loopx/extensions/lark/private_delivery_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast

from ...chat_attachments import CHAT_IMAGE_MAX_COUNT
from ...chat.attachments import CHAT_IMAGE_MAX_COUNT
from ...chat_store import RESUMABLE_SESSION_STATES, ChatSessionStore, _read_json
from ...control_plane.content_digest import BARE_SHA256_PATTERN
from ...capabilities.native_chat.file_discovery import (
Expand Down
2 changes: 1 addition & 1 deletion loopx/extensions/lark/private_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tempfile import TemporaryDirectory
from typing import Any

from ...chat_attachments import (
from ...chat.attachments import (
CHAT_IMAGE_MAX_BYTES, CHAT_IMAGE_MAX_COUNT, CHAT_IMAGE_MAX_TOTAL_BYTES, normalize_chat_image_attachments,
)
from .goal_channel_transport import call, json_payload, lark_args
Expand Down
2 changes: 1 addition & 1 deletion loopx/extensions/lark/return_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .outbound import normalize_lark_outbound_text
from .presentation.markdown_post import lark_markdown_readback_attachment_keys, lark_markdown_readback_matches
from ...capabilities.native_chat.file_discovery import read_reply_image, reply_image_attachment
from ...chat_attachments import normalize_chat_image_attachments
from ...chat.attachments import normalize_chat_image_attachments
from ...control_plane.collaboration.inbox import _hash, _read, _root, _write
from ...control_plane.collaboration.result_files import read_result_file
from ...file_lock import exclusive_file_lock
Expand Down
2 changes: 1 addition & 1 deletion loopx/presentation/codex_attached_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..agent_registry import registered_agent_ids_for_goal
from ..attached_session import load_attached_session_registry
from ..chat_attachments import CHAT_JSON_MAX_BYTES
from ..chat.attachments import CHAT_JSON_MAX_BYTES
from ..capabilities.native_chat.codex_attached import (
DesktopProtocolError,
DesktopClient,
Expand Down
2 changes: 1 addition & 1 deletion loopx/presentation/configuration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from . import decision_context_api as context_api
from . import content_media_api as media_api
from ..chat import machine_configuration_api as machine_api
from .. import chat_operator_provider_api as operator_api
from ..chat import operator_provider_api as operator_api
from ..chat import automation_cadence_api as cadence_api


Expand Down
4 changes: 2 additions & 2 deletions tests/architecture/top_level_module_budget.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schema": "loopx_top_level_module_budget_v0",
"baseline_commit": "41ea75e89892ed88d0ae543e97e31aad0a181c47",
"max_top_level_modules": 122,
"baseline_commit": "db76a91f0cc1afb8b10505a94b0a44cf017aaa69",
"max_top_level_modules": 119,
"allowlist": ["__init__.py", "entrypoint.py", "cli.py"]
}
2 changes: 1 addition & 1 deletion tests/test_audit_cli_and_runtime_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def _send_error(self, message: str, status: int = 400) -> None:


def test_chat_attachments_rejects_bool_and_list_sizes() -> None:
from loopx.chat_attachments import normalize_chat_image_attachments
from loopx.chat.attachments import normalize_chat_image_attachments

data = base64.b64encode(b"img").decode("ascii")
for bad_size in (True, False, [3], "3"):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chat_dsh_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import pytest

from loopx import chat_dsh
from loopx.chat import dsh as chat_dsh
from loopx.chat import CHAT_REVIEW_CLOSE_TAG, CHAT_REVIEW_OPEN_TAG
from loopx.chat_agent import CodexChatAgentError
from loopx.chat_dsh import (
from loopx.chat.dsh import (
HISTORY_LIMIT,
MANAGED_HOST_CHAT_FAILED,
MANAGED_HOST_CHAT_SEGMENT_IN_FLIGHT,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chat_image_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import pytest

from loopx.chat_attachments import normalize_chat_image_attachments
from loopx.chat_attachments import CHAT_TURN_MAX_BODY_BYTES, validate_chat_turn_envelope
from loopx.chat.attachments import normalize_chat_image_attachments
from loopx.chat.attachments import CHAT_TURN_MAX_BODY_BYTES, validate_chat_turn_envelope


PNG_BYTES = base64.b64decode(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_chat_image_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pytest

from loopx.chat_runtime import ChatRuntimeController
from loopx.chat_attachments import CHAT_TURN_MAX_BODY_BYTES
from loopx.chat.attachments import CHAT_TURN_MAX_BODY_BYTES
from loopx.chat_server import ChatHTTPServer, ChatRequestHandler
from loopx.chat_store import ChatSessionStore

Expand Down
9 changes: 9 additions & 0 deletions tests/test_chat_internal_module_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
from pathlib import Path

import loopx.chat as public_chat
from loopx.chat.attachments import normalize_chat_attachments
from loopx.chat.automation_cadence_api import AutomationCadenceRequestMixin
from loopx.chat.dsh import DshChatAdapter
from loopx.chat.event_cache import ChatEventCache
from loopx.chat.goal_configuration_api import GoalConfigurationRequestMixin
from loopx.chat.machine_configuration_api import MachineConfigurationRequestMixin
from loopx.chat.monitor_actions import ChatMonitorActionMixin
from loopx.chat.operator_provider_api import OperatorProviderRequestMixin
from loopx.chat.session_open import open_chat_session
from loopx.chat.ssh_source_api import SshSourceRequestMixin
from loopx.chat.status_api import ChatStatusRequestMixin, goal_read_runtime_root
Expand All @@ -23,17 +26,20 @@
def test_chat_internal_helpers_load_below_the_public_chat_namespace() -> None:
namespace_root = Path(public_chat.__file__).with_suffix("").resolve()
assert [Path(entry).resolve() for entry in public_chat.__path__] == [namespace_root]
assert normalize_chat_attachments.__module__ == "loopx.chat.attachments"
assert (
AutomationCadenceRequestMixin.__module__
== "loopx.chat.automation_cadence_api"
)
assert DshChatAdapter.__module__ == "loopx.chat.dsh"
assert ChatEventCache.__module__ == "loopx.chat.event_cache"
assert GoalConfigurationRequestMixin.__module__ == "loopx.chat.goal_configuration_api"
assert (
MachineConfigurationRequestMixin.__module__
== "loopx.chat.machine_configuration_api"
)
assert ChatMonitorActionMixin.__module__ == "loopx.chat.monitor_actions"
assert OperatorProviderRequestMixin.__module__ == "loopx.chat.operator_provider_api"
assert open_chat_session.__module__ == "loopx.chat.session_open"
assert SshSourceRequestMixin.__module__ == "loopx.chat.ssh_source_api"
assert ChatTodoActionMixin.__module__ == "loopx.chat.todo_actions"
Expand All @@ -44,6 +50,9 @@ def test_chat_internal_helpers_load_below_the_public_chat_namespace() -> None:

def test_chat_internal_helpers_have_no_top_level_compatibility_shims() -> None:
for old_module in (
"loopx.chat_attachments",
"loopx.chat_dsh",
"loopx.chat_operator_provider_api",
"loopx.chat_status_api",
"loopx.chat_event_cache",
"loopx.chat_automation_cadence_api",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lark_private_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ def close_during_control_read():
_atomic_write_json(manifest, plan)
if fault == "unlisted_cached_redirect":
import base64
from loopx.chat_attachments import normalize_chat_image_attachments
from loopx.chat.attachments import normalize_chat_image_attachments

legacy_attachments = normalize_chat_image_attachments([
{"id": f"reply-image-{index}", "name": f"original-{index}.png", "mime_type": "image/png",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_manager_context_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ def message(payload):


def test_download_attachment_does_not_expand_chat_input_admission(returned_file_history):
from loopx.chat_attachments import normalize_chat_attachments
from loopx.chat.attachments import normalize_chat_attachments

root, registry, store, session, _, _, message, _, _ = returned_file_history
visible = project_chat_return_deliveries(root, session["session_id"], [message], source_store=store, registry=registry)[0]
Expand Down
Loading