Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const capabilityCopy: Record<WorkspaceLocale, Record<string, LocalizedCopy>> = {
displayName: "Model and executor",
description: "Guides the steward executor, model, and selection boundary for this machine. A pinned route blocks substitution; a flexible pool permits only authorized fallback.",
},
steward_memory: {
displayName: "Isolated OpenViking memory",
description: "Connects owner private steward conversations to an isolated OpenViking memory namespace with per-speaker preferences and bounded recall.",
},
todo_replan_cadence: { displayName: "Goal review and stride", description: "Set review frequency and optionally choose a versioned stride strategy for work scope and route changes." },
change_quality_qualification: {
displayName: "Change quality qualification",
Expand Down Expand Up @@ -95,6 +99,10 @@ const capabilityCopy: Record<WorkspaceLocale, Record<string, LocalizedCopy>> = {
displayName: "模型与执行器",
description: "配置本机管家的执行器、模型与选择边界;锁定路径禁止替代,灵活池只允许在已授权范围内回退。",
},
steward_memory: {
displayName: "独立 OpenViking 长期记忆",
description: "为本人私聊管家启用独立身份的 OpenViking 记忆命名空间:按已验证发言人持久化偏好、跨会话按需检索并限制超时,不向群聊或工作 Agent 泄露。",
},
todo_replan_cadence: { displayName: "Goal 复盘与步幅", description: "设置复盘周期,可选用带版本的步幅策略,调节工作大小与路线变化。" },
change_quality_qualification: {
displayName: "变更质量验证",
Expand Down Expand Up @@ -164,6 +172,9 @@ const fieldCopy: Record<WorkspaceLocale, FieldCopy> = {
eligible_endpoints: { label: "Flexible eligible executors", description: "One authorized executor per line. Use only with flexible selection and include the primary executor." },
executor_model: { label: "Model", description: "Optional model for the selected executor. Leave blank to keep the executor's own default." },
executor_reasoning_effort: { label: "Reasoning effort", description: "Optional reasoning effort for the selected executor. Leave blank to keep the executor's own default." },
user_space: { label: "User space", description: "OpenViking user space isolating steward memory on this machine." },
auto_recall: { label: "Auto recall history", description: "Search past steward events automatically on substantive private messages." },
recall_timeout_seconds: { label: "Recall timeout (seconds)", description: "Wait budget (1–15s) before continuing without recalled memory." },
count_unit: { label: "Review after", description: "Work Turns require accepted settlement; polls and retries do not count.", options: { completed_todos: "Completed Todos", effective_turns: "Settled work Turns" } },
planning_horizon_goal: { label: "Show Goal in planning horizon", description: "Default on. Keep the original Goal and acceptance visible before choosing work. Turn off for rollback or comparisons; replan, stride and execution authority are unchanged." },
yardstick_enabled: { label: "Review measurement criteria", description: "Default off. Review measurement scope and feedback using available Explore evidence. Requires Explore evidence; does not enable it or authorize execution." },
Expand Down Expand Up @@ -202,6 +213,9 @@ const fieldCopy: Record<WorkspaceLocale, FieldCopy> = {
eligible_endpoints: { label: "灵活池可用执行器", description: "每行一个已授权执行器,仅用于 flexible;必须包含首选执行器。" },
executor_model: { label: "模型", description: "所选执行器使用的模型,可留空;留空表示沿用执行器自身的默认模型。" },
executor_reasoning_effort: { label: "推理档位", description: "所选执行器使用的推理档位,可留空;留空表示沿用执行器自身的默认档位。" },
user_space: { label: "记忆用户空间", description: "本机管家在 OpenViking 中隔离使用的 user space 标识。" },
auto_recall: { label: "跨会话自动召回", description: "收到非命令的实质私聊消息时,执行一次有界历史事件检索。" },
recall_timeout_seconds: { label: "召回超时(秒)", description: "等待记忆读取的上限(1–15 秒);超时后跳过记忆直接恢复正常回复。" },
count_unit: { label: "复核计数依据", description: "有效工作 Turn 须完成结算;轮询和重复重试不计数。", options: { completed_todos: "已完成 Todo", effective_turns: "已结算工作 Turn" } },
planning_horizon_goal: { label: "在规划视野中显示 Goal", description: "默认开启,选择工作前可见原目标与验收要求。可为回滚或对照实验关闭;不改变复盘、步幅策略或执行权限。" },
yardstick_enabled: { label: "复核衡量标准", description: "默认关闭。使用已有 Explore 证据复核测量范围与反馈;需有可用的 Explore 证据,不会自动启用它或授予执行权限。" },
Expand Down Expand Up @@ -280,6 +294,11 @@ export function localizedCapabilityFieldCopy(locale: WorkspaceLocale, capability
label: "Exploration mode", description: "Planning includes the evidence graph; worker and execution permissions remain separate.",
options: {off: "Off", evidence: "Evidence only", planning: "Evidence and planning"},
}};
if (capabilityId === "steward_memory") return {...fieldCopy[locale], enabled: locale === "zh-CN" ? {
label: "启用", description: "为本人私聊管家开启独立 OpenViking 长期记忆。",
} : {
label: "Enabled", description: "Enable isolated OpenViking long-term memory for owner private steward conversations.",
}};
return fieldCopy[locale];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export function MachineConfigurationSettings({ section, onChanged }: {
(inspection?.capability_catalog.capabilities ?? []).filter((capability) =>
capability.available_scopes.includes("machine")
&& (section === "conversation" ? capability.capability_id === "codex_chat" : section === "steward"
? capability.capability_id === "steward_executor" || capability.capability_id === "manager_runtime"
: capability.capability_id !== "steward_executor" && capability.capability_id !== "manager_runtime" && capability.capability_id !== "codex_chat")),
? capability.capability_id === "steward_executor" || capability.capability_id === "manager_runtime" || capability.capability_id === "steward_memory"
: capability.capability_id !== "steward_executor" && capability.capability_id !== "manager_runtime" && capability.capability_id !== "steward_memory" && capability.capability_id !== "codex_chat")),
locale,
), [inspection, locale, section]);
const invalidNamespace = inspection?.invalid_namespaces[0];
Expand Down Expand Up @@ -526,6 +526,15 @@ export function MachineConfigurationSettings({ section, onChanged }: {
</section>
) : null}

{selected.capability_id === "steward_memory" ? (
<section className="personal-capability-behavior-note">
<ShieldCheck aria-hidden size={18} />
<div><strong>{locale === "zh-CN" ? "仅限本人私聊与独立身份" : "Owner private chats only"}</strong><ContextHelp label={locale === "zh-CN" ? "管家记忆隔离说明" : "Steward memory isolation"}><p>{locale === "zh-CN"
? "连接信息读取自本机管家私有文件,不在此表单收集;记忆按已验证发言人隔离保存,超时不阻塞正常回复,也不会进入群聊或转交给工作 Agent。"
: "Connection settings stay in the private local steward file outside this form. Memory stays isolated per verified speaker, fails open on timeout, and never enters group chats or worker handoffs."}</p></ContextHelp></div>
</section>
) : null}

{selected.capability_id === "pull_request_review" ? (
<section className="personal-capability-behavior-note">
<ShieldCheck aria-hidden size={18} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,12 @@ for (const capabilityId of [
"pull_request_review",
"reward_memory",
"steward_executor",
"steward_memory",
]) {
const matches = capabilityLocalization.match(new RegExp(`${capabilityId}:`, "g")) ?? [];
assert.equal(matches.length, 2, `${capabilityId} has English and Simplified Chinese metadata`);
}
for (const fieldKey of ["agent_orders", "allowed_domains", "coordinator_agent_id", "eligible_endpoints", "enabled", "executor_endpoint", "executor_model", "executor_reasoning_effort", "max_children", "profile", "profile_preset", "review_order", "route_ref", "safe_fix", "selection_policy", "strict_receipt", "timezone"]) {
for (const fieldKey of ["agent_orders", "allowed_domains", "auto_recall", "coordinator_agent_id", "eligible_endpoints", "enabled", "executor_endpoint", "executor_model", "executor_reasoning_effort", "max_children", "profile", "profile_preset", "recall_timeout_seconds", "review_order", "route_ref", "safe_fix", "selection_policy", "strict_receipt", "timezone", "user_space"]) {
const matches = capabilityLocalization.match(new RegExp(`^\\s+${fieldKey}:`, "gm")) ?? [];
assert.equal(matches.length, 2, `${fieldKey} has English and Simplified Chinese field copy`);
}
Expand Down
46 changes: 46 additions & 0 deletions loopx/capabilities/configuration_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,52 @@ def capability_configuration_editor(
),
],
},
"steward_memory": {
"supported_scopes": ["machine"],
"writable_scopes": ["machine"],
"fields": [
_field(
"enabled",
"Enabled",
"boolean",
required=True,
description=(
"Enable isolated OpenViking long-term memory for owner "
"private steward conversations."
),
),
_field(
"user_space",
"User space",
"text",
required=True,
description=(
"OpenViking user space isolating steward memory on this machine."
),
),
_field(
"auto_recall",
"Auto recall history",
"boolean",
required=True,
description=(
"Run one bounded search across past steward exchanges for "
"substantive private messages."
),
),
_field(
"recall_timeout_seconds",
"Recall timeout (seconds)",
"number",
minimum=1,
maximum=15,
required=True,
description=(
"Maximum wait before continuing normal replies without memory recall."
),
),
],
},
"multi_subagent": {
"supported_scopes": ["goal"],
"writable_scopes": ["goal"],
Expand Down
5 changes: 5 additions & 0 deletions loopx/capabilities/machine_configuration/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
"loopx.capabilities.steward_executor.machine_defaults",
"steward_executor_machine_configuration_namespace",
),
(
"steward_memory",
"loopx.capabilities.steward_memory.machine_defaults",
"steward_memory_machine_configuration_namespace",
),
)


Expand Down
4 changes: 3 additions & 1 deletion loopx/capabilities/native_chat/codex_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def require_session_home(base_home: Path, session: Mapping[str, Any]) -> None:


def process_environment(home: Path, *, isolated: bool) -> dict[str, str]:
from ..steward_memory.runtime import scrub_openviking_environment

if not isolated:
return {**os.environ, "CODEX_HOME": str(home)}
return {**scrub_openviking_environment(os.environ), "CODEX_HOME": str(home)}
host_home = home.parent
host_home.mkdir(parents=True, exist_ok=True, mode=0o700)
home.mkdir(exist_ok=True, mode=0o700)
Expand Down
4 changes: 2 additions & 2 deletions loopx/capabilities/native_chat/external_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ def execute_turn(controller: Any, adapter: Any, session: dict[str, Any], turn: d
response = adapter.start_turn(text, lambda kind, payload: event_sink(kind, payload)
if kind not in {"answer.delta", "answer.final"} else None)
external._checked_answer_review(session, turn)
if any(response.get(key) for key in ("proposals", "context_handoff", "protected_action", "goal_draft", "unfinished_work")):
if any(response.get(key) for key in ("proposals", "context_handoff", "protected_action", "goal_draft", "unfinished_work", "memory_preferences")):
raise ValueError("an answer review cannot admit actions or business continuation")
if answer_review.get("context_correction") and response.get("gate") is None:
response = {**response, "gate": {"kind": "evidence_gap",
Expand Down Expand Up @@ -1186,7 +1186,7 @@ def validate_metadata_review_response(self, session: dict[str, Any], turn: dict[
handoffs = response.get("context_handoff")
expected = continuation["metadata_handoffs"]
if (not isinstance(handoffs, list) or len(handoffs) != len(expected)
or any(response.get(key) for key in ("gate", "proposals", "protected_action", "goal_draft", "unfinished_work"))
or any(response.get(key) for key in ("gate", "proposals", "protected_action", "goal_draft", "unfinished_work", "memory_preferences"))
or any(set(item) != {"goal_id", "agent_id", "brief"}
or any(item.get(key) != original[key] for key in ("goal_id", "agent_id"))
or item["brief"].get("context") != original["brief"]
Expand Down
33 changes: 33 additions & 0 deletions loopx/capabilities/steward_memory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Isolated OpenViking long-term memory capability for bound owner steward chats."""

from .machine_defaults import (
DEFAULT_RECALL_TIMEOUT_SECONDS,
DEFAULT_USER_SPACE,
STEWARD_MEMORY_NAMESPACE,
STEWARD_MEMORY_SCHEMA,
default_steward_memory_configuration,
load_effective_steward_memory_setting,
normalize_steward_memory_configuration,
steward_memory_machine_configuration_namespace,
)
from .runtime import (
clear_steward_memory_cache,
commit_steward_memory_after_turn,
recall_steward_memory_for_turn,
scrub_openviking_environment,
)

__all__ = [
"DEFAULT_RECALL_TIMEOUT_SECONDS",
"DEFAULT_USER_SPACE",
"STEWARD_MEMORY_NAMESPACE",
"STEWARD_MEMORY_SCHEMA",
"clear_steward_memory_cache",
"commit_steward_memory_after_turn",
"default_steward_memory_configuration",
"load_effective_steward_memory_setting",
"normalize_steward_memory_configuration",
"recall_steward_memory_for_turn",
"scrub_openviking_environment",
"steward_memory_machine_configuration_namespace",
]
103 changes: 103 additions & 0 deletions loopx/capabilities/steward_memory/machine_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""Machine configuration defaults and runtime owner for isolated steward memory."""
from __future__ import annotations

from collections.abc import Mapping
from pathlib import Path
from typing import Any

from ..machine_configuration.contract import MachineConfigurationNamespace

STEWARD_MEMORY_NAMESPACE = "steward_memory"
STEWARD_MEMORY_SCHEMA = "steward_memory_machine_defaults_v0"
DEFAULT_USER_SPACE = "steward"
DEFAULT_RECALL_TIMEOUT_SECONDS = 3
MIN_RECALL_TIMEOUT_SECONDS = 1
MAX_RECALL_TIMEOUT_SECONDS = 15


def default_steward_memory_configuration() -> dict[str, Any]:
"""Return the default-off machine configuration for isolated steward memory."""
return {
"schema_version": STEWARD_MEMORY_SCHEMA,
"enabled": False,
"user_space": DEFAULT_USER_SPACE,
"auto_recall": True,
"recall_timeout_seconds": DEFAULT_RECALL_TIMEOUT_SECONDS,
}


def normalize_steward_memory_configuration(raw: Mapping[str, Any]) -> dict[str, Any]:
"""Validate and normalize machine-level steward memory defaults."""
from ..context_providers.openviking_scope import OPENVIKING_IDENTITY_RE

allowed = {
"schema_version",
"enabled",
"user_space",
"auto_recall",
"recall_timeout_seconds",
}
unknown = sorted(set(raw) - allowed)
if unknown:
raise ValueError(
"steward_memory contains unsupported fields: " + ", ".join(unknown)
)
if raw.get("schema_version") != STEWARD_MEMORY_SCHEMA:
raise ValueError(f"steward_memory must use {STEWARD_MEMORY_SCHEMA}")
if type(raw.get("enabled")) is not bool:
raise ValueError("steward_memory.enabled must be a boolean")
user_space = str(raw.get("user_space") or "").strip()
if not OPENVIKING_IDENTITY_RE.fullmatch(user_space):
raise ValueError("steward_memory.user_space must use a safe identifier")
if type(raw.get("auto_recall")) is not bool:
raise ValueError("steward_memory.auto_recall must be a boolean")
timeout = raw.get("recall_timeout_seconds")
if (
type(timeout) is not int
or not MIN_RECALL_TIMEOUT_SECONDS <= timeout <= MAX_RECALL_TIMEOUT_SECONDS
):
raise ValueError(
"steward_memory.recall_timeout_seconds must be an integer between 1 and 15"
)
return {
"schema_version": STEWARD_MEMORY_SCHEMA,
"enabled": raw["enabled"],
"user_space": user_space,
"auto_recall": raw["auto_recall"],
"recall_timeout_seconds": timeout,
}


def steward_memory_machine_configuration_namespace() -> MachineConfigurationNamespace:
"""Describe the steward_memory machine configuration owner."""
return MachineConfigurationNamespace(
namespace=STEWARD_MEMORY_NAMESPACE,
schema_versions=frozenset({STEWARD_MEMORY_SCHEMA}),
normalize=normalize_steward_memory_configuration,
project_public=lambda value: dict(value),
apply_public_update=lambda _current, update: dict(update),
title="Steward OpenViking memory",
description=(
"Enables an isolated OpenViking memory namespace for owner private steward "
"conversations with per-speaker preferences, bounded recall timeouts, and "
"strict non-leakage to group chats or worker Agents."
),
default_configuration=default_steward_memory_configuration(),
)


def load_effective_steward_memory_setting(runtime_root: Path) -> dict[str, Any]:
"""Read normalized steward_memory machine configuration or return default-off."""
from ..machine_configuration.builtins import build_builtin_machine_configuration_registry
from ..machine_configuration.store import read_machine_configuration

registry = build_builtin_machine_configuration_registry()
configuration = read_machine_configuration(
runtime_root,
registry=registry,
namespace_ids=(STEWARD_MEMORY_NAMESPACE,),
)
stored = (configuration or {}).get("namespaces", {}).get(STEWARD_MEMORY_NAMESPACE)
if isinstance(stored, Mapping):
return normalize_steward_memory_configuration(stored)
return default_steward_memory_configuration()
Loading
Loading