Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(authorization): close the remote owner read/write asymmetries
Max9cd469d7c6df
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 9f7ca1a1b..bcd3d510c 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -188,14 +188,24 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o("method", "path", "expected"),[("GET", "/api/projects", REMOTE_HTTP_ALLOWED),- ("PUT", "/api/workbench/prefs", REMOTE_HTTP_ALLOWED),+ ("GET", "/api/workbench/prefs", REMOTE_HTTP_ALLOWED),+ ("PUT", "/api/workbench/prefs", REMOTE_HTTP_LOCAL_ONLY),("PUT", "/api/resource-policies/agent/agent-1", REMOTE_HTTP_ALLOWED),("GET", "/api/models/runtime/status", REMOTE_HTTP_ALLOWED),("GET", "/api/models/agents/codex/chain", REMOTE_HTTP_ALLOWED),+ ("GET", "/api/models/turns/turn-1/provenance", REMOTE_HTTP_ALLOWED),+ # Only the local owner can start an OAuth flow, and a status poll hands+ # back that flow's authorization URL and device code - plus, once a Model+ # Hub flow succeeds, the credential and account payload `/api/models/+ # sources` keeps local. Polling follows its flow and stays local too.+ ("GET", "/api/models/oauth/status/oaf_test0001", REMOTE_HTTP_LOCAL_ONLY),+ ("GET", "/api/backend/codex/auth/oauth/status/flow-1", REMOTE_HTTP_LOCAL_ONLY),("GET", "/api/backend/codex/runtime", REMOTE_HTTP_LOCAL_ONLY),("GET", "/api/opencode/permission-status", REMOTE_HTTP_LOCAL_ONLY),("GET", "/api/vault/audit", REMOTE_HTTP_ALLOWED),- ("POST", "/api/dock/pins", REMOTE_HTTP_ALLOWED),+ ("GET", "/api/dock", REMOTE_HTTP_ALLOWED),+ ("POST", "/api/dock/pins", REMOTE_HTTP_LOCAL_ONLY),+ ("PUT", "/api/dock/order", REMOTE_HTTP_LOCAL_ONLY),("POST", "/api/web-push/subscriptions", REMOTE_HTTP_ALLOWED),("GET", "/api/harness/runs/run-1", REMOTE_HTTP_LOCAL_ONLY),("GET", "/api/users", REMOTE_HTTP_LOCAL_ONLY),@@ -213,11 +223,12 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o("HEAD", "/status", REMOTE_HTTP_LOCAL_ONLY),("POST", "/api/show-pages/ses-1/ensure", REMOTE_HTTP_ALLOWED),("GET", "/api/memory/settings", REMOTE_HTTP_ALLOWED),- ("HEAD", "/api/memory/log/entry", REMOTE_HTTP_ALLOWED),- ("PATCH", "/api/memory/settings", REMOTE_HTTP_ALLOWED),+ ("HEAD", "/api/memory/log/entry", REMOTE_HTTP_LOCAL_ONLY),+ ("PATCH", "/api/memory/settings", REMOTE_HTTP_LOCAL_ONLY),("POST", "/api/memory/search", REMOTE_HTTP_ALLOWED),- ("POST", "/api/memory/runtime/restart", REMOTE_HTTP_ALLOWED),- ("POST", "/api/memory/clear", REMOTE_HTTP_ALLOWED),+ ("POST", "/api/memory/runtime/restart", REMOTE_HTTP_LOCAL_ONLY),+ ("POST", "/api/memory/clear", REMOTE_HTTP_LOCAL_ONLY),+ ("GET", "/api/projects/proj-1/agents-md", REMOTE_HTTP_LOCAL_ONLY),("GET", "/show/ses-1/", REMOTE_HTTP_ALLOWED),("POST", "/show/ses-1/__show/events", REMOTE_HTTP_ALLOWED),("POST", "/api/config", REMOTE_HTTP_PAYLOAD_FILTERED),@@ -286,12 +297,13 @@ def test_remote_http_policy_keeps_approved_management_and_read_surfaces(REMOTE_HTTP_PAYLOAD_FILTERED,),("canArchiveProjects", "DELETE", "/api/projects/proj-1", REMOTE_HTTP_LOCAL_ONLY),- # canEditProjectInstructions: AGENTS.md reads remotely, saves locally.+ # canEditProjectInstructions: local in both directions, because an+ # AGENTS.md / CLAUDE.md symlink can resolve outside the Project.("canEditProjectInstructions","GET","/api/projects/proj-1/agents-md",- REMOTE_HTTP_ALLOWED,+ REMOTE_HTTP_LOCAL_ONLY,),("canEditProjectInstructions",@@ -302,6 +314,34 @@ def test_remote_http_policy_keeps_approved_management_and_read_surfaces(# canEditAgentDefinitions: catalog reads remotely, definition writes locally.("canEditAgentDefinitions", "GET", "/api/agents", REMOTE_HTTP_ALLOWED),("canEditAgentDefinitions", "POST", "/api/agents", REMOTE_HTTP_LOCAL_ONLY),+ # canAdministerMemory: principal-scoped reads and search stay remote,+ # the cross-principal admin log and the sidecar administration do not.+ ("canAdministerMemory", "GET", "/api/memory/status", REMOTE_HTTP_ALLOWED),+ ("canAdministerMemory", "GET", "/api/memory/profile", REMOTE_HTTP_ALLOWED),+ ("canAdministerMemory", "POST", "/api/memory/search", REMOTE_HTTP_ALLOWED),+ ("canAdministerMemory", "GET", "/api/memory/log", REMOTE_HTTP_LOCAL_ONLY),+ ("canAdministerMemory", "GET", "/api/memory/log/entry", REMOTE_HTTP_LOCAL_ONLY),+ ("canAdministerMemory", "PATCH", "/api/memory/settings", REMOTE_HTTP_LOCAL_ONLY),+ (+ "canAdministerMemory",+ "POST",+ "/api/memory/runtime/restart",+ REMOTE_HTTP_LOCAL_ONLY,+ ),+ ("canAdministerMemory", "POST", "/api/memory/clear", REMOTE_HTTP_LOCAL_ONLY),+ # Dock/Workbench prefs: the read is remote, the process-global writes+ # are local until the records are keyed by the authenticated subject.+ ("dockAndWorkbenchPrefs", "GET", "/api/dock", REMOTE_HTTP_ALLOWED),+ ("dockAndWorkbenchPrefs", "GET", "/api/workbench/prefs", REMOTE_HTTP_ALLOWED),+ ("dockAndWorkbenchPrefs", "POST", "/api/dock/pins", REMOTE_HTTP_LOCAL_ONLY),+ (+ "dockAndWorkbenchPrefs",+ "DELETE",+ "/api/dock/pins/ses-1",+ REMOTE_HTTP_LOCAL_ONLY,+ ),+ ("dockAndWorkbenchPrefs", "PUT", "/api/dock/order", REMOTE_HTTP_LOCAL_ONLY),+ ("dockAndWorkbenchPrefs", "PUT", "/api/workbench/prefs", REMOTE_HTTP_LOCAL_ONLY),],)def test_local_only_workbench_gates_match_the_remote_http_policy(diff --git a/tests/test_resource_acl_show_pages.py b/tests/test_resource_acl_show_pages.pyindex 49a395e3a..a5799f203 100644--- a/tests/test_resource_acl_show_pages.py+++ b/tests/test_resource_acl_show_pages.py@@ -285,7 +285,12 @@ def test_remote_dock_filters_private_pins_and_authorizes_mutations(monkeypatch,environ_base=_remote_peer(),)assert response.status_code == 403- assert response.get_json()["code"] == "resource_access_forbidden"+ # The Dock record is process-global rather than keyed by the authenticated+ # subject, so every remote mutation now stops at the transport boundary+ # before the resource ACL is consulted - a stricter refusal than the+ # per-page `resource_access_forbidden` this once returned. The ACL itself is+ # unchanged and still enforced in-process, as the `api.*` calls above assert.+ assert response.get_json()["code"] == "remote_execution_disabled"def test_remote_admin_dock_order_preserves_hidden_private_pins(monkeypatch, tmp_path) -> None:diff --git a/tests/test_ui_memory_routes.py b/tests/test_ui_memory_routes.pyindex 03ab7c145..b01e5dbe9 100644--- a/tests/test_ui_memory_routes.py+++ b/tests/test_ui_memory_routes.py@@ -134,7 +134,7 @@ def test_memory_authenticated_avibe_cloud_uses_the_remote_workbench_principal(calls.append(("profile", user_key))return {"status_code": 200, "body": {"status": "ok", "items": []}}- async def clear(*, user_key: str):+ async def clear(*, user_key: str): # pragma: no cover - must stay unreachedcalls.append(("clear", user_key))return {"status_code": 200, "body": {"status": "completed", "epoch": 2}}@@ -171,14 +171,25 @@ def test_memory_authenticated_avibe_cloud_uses_the_remote_workbench_principal(assert settings_response.status_code == 200assert "diagnostics" not in settings_response.get_json()assert profile_response.status_code == 200- assert clear_response.status_code == 200- assert calls == [- ("profile", "avibe:remote:user-1"),- ("clear", "avibe:remote:user-1"),- ]+ # The profile read is genuinely scoped to the remote principal, so it keeps+ # crossing the tunnel under that principal's user key. `clear` only carries+ # the key as proof of identity: the internal route discards it and calls the+ # global `runtime.clear()`, which would erase every principal's memcells and+ # the provider root, so the remote boundary refuses it before the handler.+ assert clear_response.status_code == 403+ assert clear_response.get_json()["code"] == "remote_execution_disabled"+ assert calls == [("profile", "avibe:remote:user-1")]+++def test_memory_settings_patch_is_rejected_for_remote_ui(monkeypatch, tmp_path) -> None:+ """A remote principal cannot patch Memory settings at all, diagnostics included.+ The patch repoints the shared LLM and embedding endpoints and immediately+ reconciles the local sidecar, so the remote boundary refuses it before the+ payload is even parsed; the diagnostics field it used to reject by hand is+ only the most sensitive part of a record that is process-global throughout.+ """-def test_memory_diagnostics_patch_is_rejected_for_remote_ui(monkeypatch, tmp_path) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_remote_config(tmp_path)client = app.test_client()@@ -202,8 +213,8 @@ def test_memory_diagnostics_patch_is_rejected_for_remote_ui(monkeypatch, tmp_patenviron_base={"REMOTE_ADDR": "203.0.113.10"},)- assert response.status_code == 400- assert response.get_json() == {"status": "failed", "error": "memory_invalid_input"}+ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"assert calls == []assert V2Config.load().memory.diagnostics.log_provider_calls is True@@ -827,125 +838,82 @@ def test_memory_restart_route_shares_retained_request_and_blocks_settings_after_asyncio.run(_go())-def test_memory_restart_route_isolates_remote_session_cookie_renewal(+def test_memory_restart_route_refuses_concurrent_remote_principals(monkeypatch,tmp_path,) -> None:+ """Restarting the sidecar is local-only, so no remote caller reaches the task.++ This route once served remote principals, and its retained request task made+ two concurrent remote callers share one Response, which mixed their session+ cookie renewals. A restart acts on the whole local sidecar rather than on one+ principal, so the boundary now refuses it outright and that cross-principal+ renewal is unreachable rather than merely fixed - which is what this asserts,+ with two overlapping remote callers so a partial gate cannot pass.+ """+monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_remote_config(tmp_path)- restart_started = asyncio.Event()- release_restart = asyncio.Event()- second_waiter_joined = asyncio.Event()restart_calls: list[bool] = []- restart_waiters = 0- async def restart():+ async def restart(): # pragma: no cover - must stay unreachedrestart_calls.append(True)- restart_started.set()- await release_restart.wait()return {"status_code": 200, "body": {"ok": True, "state": "ready"}}monkeypatch.setattr(internal_client, "memory_restart", restart)- restart_request_task = ui_memory_routes._memory_restart_request_task-- def tracked_restart_request_task():- nonlocal restart_waiters- restart_waiters += 1- if restart_waiters == 2:- second_waiter_joined.set()- return restart_request_task()-- monkeypatch.setattr(- ui_memory_routes,- "_memory_restart_request_task",- tracked_restart_request_task,- )async def _go() -> tuple[httpx.Response, httpx.Response]:- completed_after_hooks = 0- after_hooks_released = asyncio.Event()-- async def hold_after_hooks(response):- nonlocal completed_after_hooks- completed_after_hooks += 1- if completed_after_hooks == 2:- after_hooks_released.set()- await after_hooks_released.wait()- return response-- # Run this after the normal hooks so both renewal mutations are present- # before either response is sent. Sharing a Response then fails- # deterministically instead of depending on ASGI scheduling.- app._after_request_handlers.insert(0, hold_after_hooks)- try:- origin = "https://alex.avibe.bot"- first_transport = httpx.ASGITransport(app=app, client=("203.0.113.10", 12345))- second_transport = httpx.ASGITransport(app=app, client=("203.0.113.11", 12346))- first_cookies = {- remote_access.SESSION_COOKIE_NAME: _renewable_remote_session_cookie(- config,- "[email protected]",- "user-1",- ),- "vibe_csrf_token": "csrf-one",- }- second_cookies = {- remote_access.SESSION_COOKIE_NAME: _renewable_remote_session_cookie(- config,- "[email protected]",- "user-2",- ),- "vibe_csrf_token": "csrf-two",- }- async with (- httpx.AsyncClient(- transport=first_transport,- base_url=origin,- cookies=first_cookies,- ) as first_client,- httpx.AsyncClient(- transport=second_transport,- base_url=origin,- cookies=second_cookies,- ) as second_client,- ):- first = asyncio.create_task(- first_client.post(- "/api/memory/runtime/restart",- json={},- headers={"Origin": origin, "X-Vibe-CSRF-Token": "csrf-one"},- )+ origin = "https://alex.avibe.bot"+ first_transport = httpx.ASGITransport(app=app, client=("203.0.113.10", 12345))+ second_transport = httpx.ASGITransport(app=app, client=("203.0.113.11", 12346))+ first_cookies = {+ remote_access.SESSION_COOKIE_NAME: _renewable_remote_session_cookie(+ config,+ "[email protected]",+ "user-1",+ ),+ "vibe_csrf_token": "csrf-one",+ }+ second_cookies = {+ remote_access.SESSION_COOKIE_NAME: _renewable_remote_session_cookie(+ config,+ "[email protected]",+ "user-2",+ ),+ "vibe_csrf_token": "csrf-two",+ }+ async with (+ httpx.AsyncClient(+ transport=first_transport,+ base_url=origin,+ cookies=first_cookies,+ ) as first_client,+ httpx.AsyncClient(+ transport=second_transport,+ base_url=origin,+ cookies=second_cookies,+ ) as second_client,+ ):+ first = asyncio.create_task(+ first_client.post(+ "/api/memory/runtime/restart",+ json={},+ headers={"Origin": origin, "X-Vibe-CSRF-Token": "csrf-one"},)- await restart_started.wait()- second = asyncio.create_task(- second_client.post(- "/api/memory/runtime/restart",- json={},- headers={"Origin": origin, "X-Vibe-CSRF-Token": "csrf-two"},- )+ )+ second = asyncio.create_task(+ second_client.post(+ "/api/memory/runtime/restart",+ json={},+ headers={"Origin": origin, "X-Vibe-CSRF-Token": "csrf-two"},)- await second_waiter_joined.wait()- release_restart.set()- return await asyncio.wait_for(asyncio.gather(first, second), timeout=2.0)- finally:- app._after_request_handlers.remove(hold_after_hooks)+ )+ return await asyncio.wait_for(asyncio.gather(first, second), timeout=5.0)first_response, second_response = asyncio.run(_go())- def renewed_subject(response: httpx.Response) -> str:- session_headers = [- value- for value in response.headers.get_list("set-cookie")- if value.startswith(f"{remote_access.SESSION_COOKIE_NAME}=")- ]- assert len(session_headers) == 1- cookie_value = session_headers[0].split(";", 1)[0].split("=", 1)[1]- payload = remote_access.parse_session_cookie(config, cookie_value)- assert payload is not None- return str(payload["sub"])-- assert restart_calls == [True]- assert first_response.status_code == 200- assert second_response.status_code == 200- assert renewed_subject(first_response) == "user-1"- assert renewed_subject(second_response) == "user-2"+ assert restart_calls == []+ assert first_response.status_code == 403+ assert second_response.status_code == 403+ assert first_response.json()["code"] == "remote_execution_disabled"+ assert second_response.json()["code"] == "remote_execution_disabled"diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex 879eff487..69ffdc59a 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -1835,6 +1835,94 @@ def test_local_show_event_stream_keeps_the_screenshot_path() -> None:)+def _deny_show_page_acl(monkeypatch, *, allowed: bool) -> list[tuple[str, str]]:+ """Record the Show Page ACL checks the workbench stream makes."""++ from storage import resource_access_service++ checks: list[tuple[str, str]] = []++ def _can_use_resource(context, resource_kind, resource_id, **kwargs):+ checks.append((resource_kind, resource_id))+ return allowed++ monkeypatch.setattr(resource_access_service, "can_use_resource", _can_use_resource)+ return checks+++def test_remote_owner_show_event_requires_the_show_page_acl(monkeypatch) -> None:+ """An Instance owner does not override a Show Page's own resource policy.++ Direct reads of a private page whose policy names another subject already+ deny this owner, so the workbench SSE must not forward the same page's+ annotation text and attachment metadata either.+ """++ from vibe.authorization import AuthorizationContext++ checks = _deny_show_page_acl(monkeypatch, allowed=False)+ remote_owner = AuthorizationContext(+ instance_role="owner",+ subject="[email protected]",+ is_remote=True,+ )++ assert (+ ui_server._workbench_event_visible_to_context(+ remote_owner, "show.event", _show_event_frame()+ )+ is False+ )+ assert checks == [("show_page", "ses123")]+++def test_remote_owner_show_event_passes_the_allowed_show_page(monkeypatch) -> None:+ from vibe.authorization import AuthorizationContext++ checks = _deny_show_page_acl(monkeypatch, allowed=True)+ remote_owner = AuthorizationContext(+ instance_role="owner",+ subject="[email protected]",+ is_remote=True,+ )++ assert (+ ui_server._workbench_event_visible_to_context(+ remote_owner, "show.event", _show_event_frame()+ )+ is True+ )+ assert checks == [("show_page", "ses123")]+++def test_show_event_without_a_session_is_dropped(monkeypatch) -> None:+ from vibe.authorization import AuthorizationContext++ _deny_show_page_acl(monkeypatch, allowed=True)+ remote_owner = AuthorizationContext(instance_role="owner", is_remote=True)++ assert (+ ui_server._workbench_event_visible_to_context(+ remote_owner,+ "show.event",+ json.dumps({"type": "show.event", "data": {"id": "evt-1"}}),+ )+ is False+ )+++def test_local_show_event_skips_the_remote_acl(monkeypatch) -> None:+ """A trusted-local subscriber has no authorization context to evaluate."""++ checks = _deny_show_page_acl(monkeypatch, allowed=False)++ assert (+ ui_server._workbench_event_visible_to_context(None, "show.event", _show_event_frame())+ is True+ )+ assert checks == []++@pytest.mark.parametrize(("method", "path", "json_body", "api_method"),[@@ -2162,10 +2250,17 @@ def test_remote_queue_deletion_is_blocked_before_store_access(assert response.get_json()["code"] == "remote_execution_disabled"-def test_remote_owner_can_still_read_agent_instructions_and_queue(+def test_remote_owner_instruction_reads_stay_local_while_queue_reads_do_not(monkeypatch,tmp_path,):+ """Project and global instructions are local reads; the queue is not.++ A checked-out ``AGENTS.md`` / ``CLAUDE.md`` can be a symlink pointing+ outside the Project, and a remote caller holds no file capability to+ follow it, so the read stays trusted-local like the global prompts.+ """+from storage.importer import ensure_sqlite_statemonkeypatch.setenv("AVIBE_HOME", str(tmp_path))@@ -2199,8 +2294,8 @@ def test_remote_owner_can_still_read_agent_instructions_and_queue(environ_base=_remote_peer(),)- assert project_response.status_code == 200- assert project_response.get_json()["source"] == "none"+ assert project_response.status_code == 403+ assert project_response.get_json()["code"] == "remote_execution_disabled"assert global_response.status_code == 403assert global_response.get_json()["code"] == "remote_execution_disabled"assert queue_response.status_code == 200@@ -2430,7 +2525,9 @@ def test_remote_instance_role_route_matrix(assert config_response.status_code == 200assert prefs_read_response.status_code == 200assert prefs_read_response.get_json()["background_work_banner_enabled"] is True- assert prefs_write_response.status_code == (200 if role == "owner" else 403)+ # The prefs record is process-global rather than per-principal, so the read+ # crosses the tunnel for every role while the write stays trusted-local.+ assert prefs_write_response.status_code == 403# Role grants an authorized remote operation, not trusted-local visibility.# All remote callers receive the same explicit safe config projection.assert set(config_response.get_json()) == {diff --git a/ui/src/components/settings/SettingsMemoryPage.test.tsx b/ui/src/components/settings/SettingsMemoryPage.test.tsxindex a43f8b991..25b5c0766 100644--- a/ui/src/components/settings/SettingsMemoryPage.test.tsx+++ b/ui/src/components/settings/SettingsMemoryPage.test.tsx@@ -7,6 +7,8 @@ import { MemoryRouter } from 'react-router-dom';import { SettingsMemoryPage } from './SettingsMemoryPage';import type { MemoryStatus } from '../../context/ApiContext';+import { InstanceAuthorizationContext } from '../../context/InstanceAuthorizationContext';+import { DENIED_INSTANCE_CAPABILITIES } from '../../lib/sessionInfo';const api = vi.hoisted(() => ({clearMemory: vi.fn(),@@ -247,3 +249,45 @@ describe('SettingsMemoryPage disabled recorder health', () => {expect(screen.getByRole('button', { name: 'memory.status.restartEngine' })).toBeTruthy();});});++describe('SettingsMemoryPage remote administration gate', () => {+ // A remote Instance owner keeps `can_manage_instance`, so only the locality+ // half of the gate can keep the local-only administration routes off screen.+ const renderRemoteOwner = () =>+ render(+ <MemoryRouter>+ <InstanceAuthorizationContext.Provider+ value={{+ remote: true,+ instanceRole: 'owner',+ capabilities: { ...DENIED_INSTANCE_CAPABILITIES, can_manage_instance: true },+ }}+ >+ <SettingsMemoryPage />+ </InstanceAuthorizationContext.Provider>+ </MemoryRouter>,+ );++ it('hides the admin log, the settings tab and the engine restart from a remote owner', async () => {+ renderRemoteOwner();++ expect(await screen.findByRole('radio', { name: 'memory.tabs.status' })).toBeTruthy();+ expect(screen.getByRole('radio', { name: 'memory.tabs.search' })).toBeTruthy();+ expect(screen.queryByRole('radio', { name: 'memory.tabs.log' })).toBeNull();+ expect(screen.queryByRole('radio', { name: 'memory.tabs.settings' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'memory.status.restartEngine' })).toBeNull();+ });++ it('replaces the remote setup flow with the unavailable notice', async () => {+ api.getMemorySettings.mockResolvedValue({+ status: 'ok',+ enabled: false,+ processing: { llm: endpoint, embedding: endpoint },+ });++ renderRemoteOwner();++ expect(await screen.findByText('memory.remoteUnavailable.title')).toBeTruthy();+ expect(screen.queryByRole('radio', { name: 'memory.tabs.status' })).toBeNull();+ });+});diff --git a/ui/src/components/settings/SettingsMemoryPage.tsx b/ui/src/components/settings/SettingsMemoryPage.tsxindex 70b5ac0dd..408480615 100644--- a/ui/src/components/settings/SettingsMemoryPage.tsx+++ b/ui/src/components/settings/SettingsMemoryPage.tsx@@ -14,6 +14,7 @@ import { MemorySettingsPanel } from './memory/MemorySettingsPanel';import { MemoryStatusPanel } from './memory/MemoryStatusPanel';import { useMemoryResource } from './memory/useMemoryResource';import { useApi } from '../../context/ApiContext';+import { useInstanceAuthorization } from '../../context/InstanceAuthorizationContext';import type {MemoryFailureLogEntry,MemoryFailureLogResult,@@ -23,6 +24,7 @@ import type {import { useToast } from '../../context/ToastContext';import { memoryRuntimeRecoveryAvailable, memorySetupStage } from '../../lib/memorySettings';import { memoryErrorMessage } from '../../lib/memoryRead';+import { canAdministerMemory } from '../../lib/remoteAuth';type MemoryTab = 'status' | 'profile' | 'search' | 'log' | 'settings';@@ -41,6 +43,10 @@ export const SettingsMemoryPage: React.FC = () => {const { t } = useTranslation();const api = useApi();const { showToast } = useToast();+ const { remote } = useInstanceAuthorization();+ // The admin log, the settings save and clear / runtime-restart are local-only+ // in the remote HTTP policy; status, profile and search stay remote-permitted.+ const canAdminister = canAdministerMemory({ remote });const [tab, setTab] = useState<MemoryTab>('status');const [clearOpen, setClearOpen] = useState(false);@@ -163,14 +169,26 @@ export const SettingsMemoryPage: React.FC = () => {{ id: 'status' as const, label: t('memory.tabs.status') },{ id: 'profile' as const, label: t('memory.tabs.profile') },{ id: 'search' as const, label: t('memory.tabs.search') },- { id: 'log' as const, label: t('memory.tabs.log') },- { id: 'settings' as const, label: t('memory.tabs.settings') },+ ...(canAdminister+ ? [+ { id: 'log' as const, label: t('memory.tabs.log') },+ { id: 'settings' as const, label: t('memory.tabs.settings') },+ ]+ : []),],- [t],+ [canAdminister, t],);+ // A remote principal that deep-links to an administration tab lands on status+ // rather than on a panel whose reads and writes it cannot make.+ const activeTab = tabs.some((entry) => entry.id === tab) ? tab : 'status';+const setupStage = memorySetupStage(runtimeInstalled, settings?.enabled ?? null);const runtimeRecoveryAvailable = memoryRuntimeRecoveryAvailable(runtimeInstalled, settings !== null);+ // Setup and runtime recovery exist to save settings, so they are unreachable+ // for a principal that cannot administer Memory at all.+ const administrationUnavailable =+ !canAdminister && (setupStage === 'runtime-required' || setupStage === 'setup');const settingsPanel = settings ? (<MemorySettingsPanel@@ -202,11 +220,12 @@ export const SettingsMemoryPage: React.FC = () => {subtitle={t('memory.subtitle')}>{!remoteUnavailable &&+ canAdminister &&settings?.enabled === false &&status?.recorder?.reason === 'call_log_corrupt' ? (<MemoryRecorderFaultBanner status={status} onClearAll={() => setClearOpen(true)} />) : null}- {!remoteUnavailable && settings?.enabled === true ? (+ {!remoteUnavailable && canAdminister && settings?.enabled === true ? (<div className="flex justify-end"><Buttonvariant="secondary"@@ -219,7 +238,7 @@ export const SettingsMemoryPage: React.FC = () => {</Button></div>) : null}- {remoteUnavailable ? (+ {remoteUnavailable || administrationUnavailable ? (<div className="flex flex-col items-center gap-2 rounded-2xl border border-border bg-surface p-10 text-center"><ShieldAlert className="size-6 text-muted" /><span className="text-[14px] font-semibold text-foreground">{t('memory.remoteUnavailable.title')}</span>@@ -259,11 +278,11 @@ export const SettingsMemoryPage: React.FC = () => {<><div data-testid="memory-tabs-scroll" className="max-w-full overflow-x-auto pb-1"><div className="min-w-max">- <SegmentedRadio value={tab} onChange={setTab} options={tabs} ariaLabel={t('memory.title')} tone="mint" />+ <SegmentedRadio value={activeTab} onChange={setTab} options={tabs} ariaLabel={t('memory.title')} tone="mint" /></div></div>- {tab === 'status' && (+ {activeTab === 'status' && (<MemoryStatusPanelstatus={status}failures={failuresRead.data?.items ?? []}@@ -275,15 +294,15 @@ export const SettingsMemoryPage: React.FC = () => {void loadStatus();void loadFailures();}}- onOpenSettings={() => setTab('settings')}+ onOpenSettings={canAdminister ? () => setTab('settings') : undefined}/>)}- {tab === 'profile' && <MemoryProfilePanel enabled={!!settings?.enabled} />}+ {activeTab === 'profile' && <MemoryProfilePanel enabled={!!settings?.enabled} />}- {tab === 'search' && <MemorySearchPanel enabled={!!settings?.enabled} />}+ {activeTab === 'search' && <MemorySearchPanel enabled={!!settings?.enabled} />}- {tab === 'log' && settings ? (+ {activeTab === 'log' && settings ? (<MemoryLogPanelkey={logGeneration}enabled={settings.enabled}@@ -292,7 +311,7 @@ export const SettingsMemoryPage: React.FC = () => {/>) : null}- {tab === 'settings' &&+ {activeTab === 'settings' &&(!settingsRead.loaded && !settings ? (<div className="flex items-center gap-2 px-1 text-sm text-muted"><Loader2 className="size-4 animate-spin" />diff --git a/ui/src/components/settings/memory/MemoryStatusPanel.tsx b/ui/src/components/settings/memory/MemoryStatusPanel.tsxindex c36339e93..55be1a438 100644--- a/ui/src/components/settings/memory/MemoryStatusPanel.tsx+++ b/ui/src/components/settings/memory/MemoryStatusPanel.tsx@@ -49,7 +49,9 @@ export const MemoryStatusPanel: React.FC<{loading: boolean;error: string | null;onRefresh: () => void;- onOpenSettings: () => void;+ /** Absent when the viewer cannot administer Memory (remote), which hides the+ * credential fault's settings shortcut. */+ onOpenSettings?: () => void;}> = ({status,failures,@@ -122,7 +124,7 @@ export const MemoryStatusPanel: React.FC<{<AlertTriangle className="mt-0.5 size-4 shrink-0 text-gold" /><div className="flex min-w-0 flex-col gap-2"><span>{t(`memory.status.fault.${faultKind}`)}</span>- {faultKind === 'credential' ? (+ {faultKind === 'credential' && onOpenSettings ? (<Button variant="secondary" size="xs" className="w-fit" onClick={onOpenSettings}>{t('memory.status.faultAction.credential')}</Button>diff --git a/ui/src/components/workbench/ProjectSettingsDialog.tsx b/ui/src/components/workbench/ProjectSettingsDialog.tsxindex 78c8b85ec..dffe54f56 100644--- a/ui/src/components/workbench/ProjectSettingsDialog.tsx+++ b/ui/src/components/workbench/ProjectSettingsDialog.tsx@@ -5,6 +5,7 @@ import { FileText } from 'lucide-react';import { useApi } from '../../context/ApiContext';import type { ProjectDefaultAgent, VibeAgentBrief, WorkbenchProject } from '../../context/ApiContext';+import { useInstanceAuthorization } from '../../context/InstanceAuthorizationContext';import { useWorkbenchProjectsTree } from '../../context/WorkbenchProjectsContext';import { Button } from '../ui/button';import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog';@@ -12,6 +13,7 @@ import { InfoHint } from '../ui/info-hint';import { AgentRoutePicker } from './AgentRoutePicker';import type { AgentRoutePatch } from './AgentRoutePicker';import { ProjectAgentsMdDialog } from './ProjectAgentsMdDialog';+import { canEditProjectInstructions } from '../../lib/remoteAuth';// Per-project settings. Three sections:// 1. Working directory (read-only) — where the Agent runs.@@ -29,6 +31,10 @@ export const ProjectSettingsDialog: React.FC<{const { t } = useTranslation();const api = useApi();const { setProjectDefaultAgent } = useWorkbenchProjectsTree();+ const { capabilities, remote } = useInstanceAuthorization();+ // Reading and saving AGENTS.md are both local-only, so the shortcut is only+ // offered where the editor can actually load the file.+ const canEditAgentsMd = capabilities.can_manage_projects && canEditProjectInstructions({ remote });const [agents, setAgents] = useState<VibeAgentBrief[]>([]);const [agentsMdOpen, setAgentsMdOpen] = useState(false);@@ -117,6 +123,7 @@ export const ProjectSettingsDialog: React.FC<{</section>{/* 3. Project guidance prompt → the existing AGENTS.md editor. */}+ {canEditAgentsMd ? (<section className="flex flex-col gap-1.5"><span className="text-[12px] font-semibold text-foreground">{t('projectSettings.guidance.label')}</span><Button@@ -134,12 +141,15 @@ export const ProjectSettingsDialog: React.FC<{{project.folder_path ? t('projectSettings.guidance.hint') : t('projectSettings.guidance.noFolder')}</span></section>+ ) : null}</div></DialogContent></Dialog>{/* The guidance editor layers on top; the AGENTS.md file lives in the folder. */}- <ProjectAgentsMdDialog project={project} open={agentsMdOpen} onClose={() => setAgentsMdOpen(false)} />+ {canEditAgentsMd ? (+ <ProjectAgentsMdDialog project={project} open={agentsMdOpen} onClose={() => setAgentsMdOpen(false)} />+ ) : null}</>);};diff --git a/ui/src/lib/remoteAuth.test.ts b/ui/src/lib/remoteAuth.test.tsindex 0fe6426f8..9752c7946 100644--- a/ui/src/lib/remoteAuth.test.ts+++ b/ui/src/lib/remoteAuth.test.ts@@ -8,6 +8,7 @@ const platform = vi.hoisted(() => ({vi.mock('./platform', () => platform);import {+ canAdministerMemory,canArchiveProjects,canEditAgentDefinitions,canEditProjectInstructions,@@ -42,6 +43,7 @@ describe('local-only workbench controls', () => {canUseHarness,canArchiveProjects,canEditProjectInstructions,+ canAdministerMemory,};it.each(Object.entries(predicates))('keeps %s available on a local instance', (_name, predicate) => {diff --git a/ui/src/lib/remoteAuth.ts b/ui/src/lib/remoteAuth.tsindex 51708ea99..16745bbce 100644--- a/ui/src/lib/remoteAuth.ts+++ b/ui/src/lib/remoteAuth.ts@@ -98,13 +98,25 @@ export function canArchiveProjects(context: RemoteContext): boolean {}/**- * Reading a Project's `AGENTS.md` is remote-permitted but saving it is- * local-only, so remote viewers get the instructions read-only.+ * Project instructions are local-only in both directions: saving `AGENTS.md` is+ * local, and the read is too because a checked-in `AGENTS.md` / `CLAUDE.md`+ * symlink can point outside the Project workspace, which a remote caller has no+ * file capability to follow.*/export function canEditProjectInstructions(context: RemoteContext): boolean {return isTrustedLocal(context);}+/**+ * Memory administration is local-only: the admin log enumerates memcells for+ * every principal, a settings save repoints the shared provider endpoints, and+ * clear / runtime-restart act on the whole local sidecar. The principal-scoped+ * status, profile and search reads stay remote-permitted.+ */+export function canAdministerMemory(context: RemoteContext): boolean {+ return isTrustedLocal(context);+}+export async function checkRemoteAuthForPath<Session extends RemoteSession>(path: string,diff --git a/vibe/authorization.py b/vibe/authorization.pyindex 6bab27e82..b6c1ff2a5 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -410,11 +410,12 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(frozenset({"POST"}),r"^/api/show-pages/[^/]+/ensure$",),+ # Reading the Dock is safe, but its pins/order and the Workbench prefs+ # are one process-global record shared by the local owner and every+ # remote principal. Until they are keyed by the authenticated subject a+ # remote write would reorder and re-pin everyone else's Dock and flip+ # another principal's banner preference, so the mutations stay local.(frozenset({"GET", "HEAD"}), r"^/api/dock$"),- (frozenset({"POST"}), r"^/api/dock/pins$"),- (frozenset({"DELETE"}), r"^/api/dock/pins/[^/]+$"),- (frozenset({"PUT"}), r"^/api/dock/order$"),- (frozenset({"PUT"}), r"^/api/workbench/prefs$"),(frozenset({"GET", "HEAD"}),r"^/api/web-push/(?:status|vapid-public-key)$",@@ -428,10 +429,6 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(frozenset({"PUT"}),r"^/api/resource-policies/[^/]+/[^/]+$",),- (- frozenset({"GET", "HEAD"}),- r"^/api/projects/[^/]+/agents-md$",- ),(frozenset({"GET", "HEAD"}),r"^/api/models/(?:agents|events|runtime/status)$",@@ -442,12 +439,15 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(),(frozenset({"GET", "HEAD"}),- r"^/api/models/(?:turns/[^/]+/provenance|oauth/status/[^/]+)$",- ),- (- frozenset({"GET", "HEAD"}),- r"^/api/backend/[^/]+/auth/oauth/status/[^/]+$",+ r"^/api/models/turns/[^/]+/provenance$",),+ # OAuth polling follows its flow: `oauth/start` and the Settings+ # `auth/oauth/start` are local-only, so only the local owner can open a+ # flow, while a status poll returns that flow's authorization URL and+ # device code and - once the Model Hub flow succeeds - the same+ # credential and account payload `/api/models/sources` deliberately+ # keeps local. A remote caller holding a flow id would read the local+ # owner's in-flight login, so both status routes stay local too.(frozenset({"GET", "HEAD"}),r"^/api/remote-access/status$",@@ -456,15 +456,17 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(frozenset({"GET", "HEAD"}),r"^/api/harness/counts$",),+ # Memory reads that describe this principal's own view stay remote, and+ # search is scoped to the caller. The admin log is not: its readers+ # enumerate and hydrate memcells for every principal, so it stays local.+ # Memory administration is absent for the same reason: a settings PATCH+ # repoints the shared provider endpoints, and `runtime/restart` /+ # `clear` act on the whole local sidecar rather than one principal.(frozenset({"GET", "HEAD"}),- r"^/api/memory/(?:settings|status|failures|profile|log|log/entry)$",- ),- (frozenset({"PATCH"}), r"^/api/memory/settings$"),- (- frozenset({"POST"}),- r"^/api/memory/(?:search|runtime/restart|clear)$",+ r"^/api/memory/(?:settings|status|failures|profile)$",),+ (frozenset({"POST"}), r"^/api/memory/search$"),))diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex ac862b040..e1e9cfa62 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -10486,17 +10486,36 @@ def sessions_draft_set(session_id: str):return jsonify({"ok": True})-def _workbench_event_visible_to_context(context, event_type: str, payload: str) -> bool:- if context is None or context.is_instance_owner:- return True- if event_type in {"authorization.changed", "workbench.events.bridge.status"}:- return True+def _workbench_event_data(payload: str) -> dict[str, Any] | None:try:envelope = json.loads(payload)except (TypeError, json.JSONDecodeError):- return False+ return Nonedata = envelope.get("data") if isinstance(envelope, dict) else None- if not isinstance(data, dict):+ return data if isinstance(data, dict) else None+++def _workbench_event_visible_to_context(context, event_type: str, payload: str) -> bool:+ if context is None:+ return True+ if event_type == "show.event":+ # A Show Page carries its own resource ACL, and being the Instance owner+ # does not override it: a direct read of a page whose policy names+ # another subject is denied, so the workbench stream must not hand the+ # same page's annotation text and attachment metadata to that owner+ # either. Fail closed when the frame has no session to check.+ data = _workbench_event_data(payload)+ session_id = data.get("session_id") if data else None+ if not isinstance(session_id, str) or not session_id:+ return False+ if not _show_page_resource_access_allowed(context, session_id):+ return False+ if context.is_instance_owner:+ return True+ if event_type in {"authorization.changed", "workbench.events.bridge.status"}:+ return True+ data = _workbench_event_data(payload)+ if data is None:return Falsefrom storage import project_access_service