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(auth): resolve review and CI failures for org runtime access rollout
Max0af31cf2a89c
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 9fc548dd2..0ce9bccfb 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -8,14 +8,14 @@ from vibe.authorization import (REMOTE_HTTP_LOCAL_ONLY,can_receive_workbench_event,context_from_session_payload,- has_temporary_unrestricted_org_app_access,+ has_temporary_unrestricted_org_access,http_authorization_policy,require_instance_role,trusted_local_context,)-def _remote_context(role: str) -> AuthorizationContext:+def _active_org_context(role: str) -> AuthorizationContext:return AuthorizationContext(instance_role=role,subject=f"{role}-subject",@@ -35,10 +35,10 @@ def _non_member_context(role: str = "owner") -> AuthorizationContext:)-def test_remote_roles_allow_chat_without_enabling_local_machine_capabilities() -> None:- viewer = _remote_context("viewer")- editor = _remote_context("editor")- owner = _remote_context("owner")+def test_non_member_remote_roles_keep_rank_without_local_machine_capabilities() -> None:+ viewer = _non_member_context("viewer")+ editor = _non_member_context("editor")+ owner = _non_member_context("owner")assert viewer.can_read_instance is Trueassert viewer.can_chat is False@@ -59,7 +59,7 @@ def test_remote_roles_allow_chat_without_enabling_local_machine_capabilities() -assert trusted_local_context().can_use_cloud_asr is False-def test_temporary_org_app_access_is_not_projected_as_a_capability() -> None:+def test_temporary_org_access_projects_runtime_rights_without_fake_local_capabilities() -> None:member = AuthorizationContext(instance_role="viewer",subject="member-1",@@ -70,24 +70,24 @@ def test_temporary_org_app_access_is_not_projected_as_a_capability() -> None:is_remote=True,)- assert has_temporary_unrestricted_org_app_access(member) is True+ assert has_temporary_unrestricted_org_access(member) is Trueassert member.capability_projection() == {"is_instance_owner": False,"can_read_instance": True,- "can_chat": False,- "can_manage_projects": False,- "can_manage_agents": False,- "can_manage_instance": False,- "can_use_agents": False,- "can_use_skills": False,- "can_use_vault_secrets": False,+ "can_chat": True,+ "can_manage_projects": True,+ "can_manage_agents": True,+ "can_manage_instance": True,+ "can_use_agents": True,+ "can_use_skills": True,+ "can_use_vault_secrets": True,"can_use_show_pages": True,"can_use_terminal_files": False,"can_use_terminal": False,"can_use_files": False,"can_use_system": False,}- assert has_temporary_unrestricted_org_app_access(+ assert has_temporary_unrestricted_org_access(AuthorizationContext(**{**member.__dict__,@@ -95,7 +95,7 @@ def test_temporary_org_app_access_is_not_projected_as_a_capability() -> None:})) is False- assert has_temporary_unrestricted_org_app_access(+ assert has_temporary_unrestricted_org_access(AuthorizationContext(**{**member.__dict__,@@ -124,28 +124,13 @@ def test_temporary_org_members_receive_show_events_at_viewer_instance_role() ->assert can_receive_workbench_event(non_member, "show.event") is False- ("role", "expected"),- [- (- "viewer",- {"agent": False, "skill": False, "vault_secret": False, "show_page": True},- ),- (- "editor",- {"agent": True, "skill": True, "vault_secret": True, "show_page": True},- ),- (- "owner",- {"agent": True, "skill": True, "vault_secret": True, "show_page": True},- ),- ],-)-def test_resource_use_capability_is_distinct_from_owner_management(role, expected) -> None:- context = _remote_context(role)[email protected]("role", ["viewer", "editor", "owner"])+def test_active_org_members_bypass_role_splits_for_known_runtime_resources(role) -> None:+ context = _active_org_context(role)+ expected = {"agent": True, "skill": True, "vault_secret": True, "show_page": True}assert {kind: context.can_use_resource(kind) for kind in expected} == expected- assert context.can_manage_instance is (role == "owner")+ assert context.can_manage_instance is Trueassert context.can_use_resource("future_resource") is False@@ -166,7 +151,7 @@ def test_context_uses_role_not_diagnostic_source_for_owner() -> None:assert context.is_instance_owner is Falseassert context.can_chat is True- assert context.can_manage_instance is False+ assert context.can_manage_instance is Trueassert context.authorization_revision == 0@@ -295,7 +280,7 @@ def test_http_policy_preserves_safe_remote_reads_and_show_routes() -> None:assert http_authorization_policy("POST", "/show/ses-1/__show/events").remote_access == REMOTE_HTTP_ALLOWED-def test_temporary_runtime_admission_requires_active_organization_membership() -> None:+def test_temporary_runtime_signal_requires_membership_while_role_guard_uses_rank() -> None:member = AuthorizationContext(instance_role="viewer",subject="member-1",@@ -311,9 +296,10 @@ def test_temporary_runtime_admission_requires_active_organization_membership() -instance_access_source="owner",is_remote=True,)+ assert has_temporary_unrestricted_org_access(member) is True+ assert has_temporary_unrestricted_org_access(non_member) is Falseassert require_instance_role(member, "owner") is member- with pytest.raises(InstanceAuthorizationError):- require_instance_role(non_member, "owner")+ assert require_instance_role(non_member, "owner") is non_memberdef test_temporary_runtime_route_matrix_is_not_a_capability_projection() -> None:@@ -331,9 +317,9 @@ def test_temporary_runtime_route_matrix_is_not_a_capability_projection() -> Nonedef test_workbench_event_policy_filters_privileged_and_unknown_events() -> None:- viewer = _remote_context("viewer")- editor = _remote_context("editor")- owner = _remote_context("owner")+ viewer = _active_org_context("viewer")+ editor = _active_org_context("editor")+ owner = _active_org_context("owner")non_member = _non_member_context()local = trusted_local_context()diff --git a/tests/test_resource_access_service.py b/tests/test_resource_access_service.pyindex 666a36c6e..d03df9c75 100644--- a/tests/test_resource_access_service.py+++ b/tests/test_resource_access_service.py@@ -153,7 +153,7 @@ def test_active_org_members_can_use_legacy_resources_without_forging_local_identengine.dispose()-def test_inactive_remote_identity_cannot_use_resources_even_with_owner_claim(tmp_path) -> None:+def test_non_member_role_rank_does_not_bypass_organization_resource_acl(tmp_path) -> None:db = tmp_path / "vibe.sqlite"run_migrations(db)engine = create_sqlite_engine(db)@@ -188,10 +188,13 @@ def test_inactive_remote_identity_cannot_use_resources_even_with_owner_claim(tmp"private-agent",connection=connection,)- assert not resource_access_service.can_use_resource(+ # Direct service calls retain ordinary role plus resource-policy+ # semantics; HTTP admission rejects this non-member before runtime+ # APIs can reach the service.+ assert resource_access_service.can_use_resource(removed_owner, "agent", "personal-agent", connection=connection)- assert not resource_access_service.can_manage_resource_acl(+ assert resource_access_service.can_manage_resource_acl(removed_owner, "agent", "personal-agent", connection=connection)finally:diff --git a/tests/test_resource_acl_show_pages.py b/tests/test_resource_acl_show_pages.pyindex 53b9bddc1..bcfd9668b 100644--- a/tests/test_resource_acl_show_pages.py+++ b/tests/test_resource_acl_show_pages.py@@ -152,7 +152,7 @@ def test_show_page_email_context_bypasses_audience_only_for_its_signed_page(store.close()-def test_non_org_remote_context_keeps_only_signed_show_page_entitlement(+def test_non_org_email_context_keeps_exact_page_entitlement_separate_from_role_rank(monkeypatch, tmp_path) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))@@ -179,8 +179,8 @@ def test_non_org_remote_context_keeps_only_signed_show_page_entitlement("ses-scope",connection=connection,)- assert not context.can_chat- assert not context.can_use_resource("agent")+ assert context.can_chat+ assert context.can_use_resource("agent")finally:store.close()diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex cd4541ede..d93c416c1 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -1253,10 +1253,10 @@ def test_remote_session_info_projects_active_org_signal_without_fake_capabilitieassert payload["instance_role"] == "viewer"assert payload["temporary_unrestricted_org_access"] is Trueassert payload["temporary_unrestricted_org_app_access"] is True- # The temporary signal admits runtime routes; it never fabricates owner or- # trusted-local capability bits in the browser projection.+ # The temporary signal grants runtime management without fabricating owner+ # identity or trusted-local machine capability bits.assert payload["capabilities"]["is_instance_owner"] is False- assert payload["capabilities"]["can_manage_instance"] is False+ assert payload["capabilities"]["can_manage_instance"] is Trueassert payload["capabilities"]["can_use_system"] is False@@ -3190,7 +3190,9 @@ def test_remote_show_runtime_write_is_rejected_before_runtime_invocation()assert response.status_code == 403- assert response.get_json()["error"] == "instance_access_forbidden"+ payload = response.get_json()+ assert payload["code"] == "remote_execution_disabled"+ assert payload["error"]["code"] == "remote_execution_disabled"def test_active_org_member_can_read_session_history_without_resource_acl(@@ -3355,12 +3357,14 @@ def test_non_org_remote_identity_cannot_use_runtime_apis(monkeypatch, tmp_path):session_response = client.get("/api/session", base_url="https://alex.avibe.bot")assert read_response.status_code == 403+ assert read_response.get_json()["error"] == "instance_access_forbidden"assert manage_response.status_code == 403assert manage_response.get_json()["error"] == "instance_access_forbidden"assert session_response.status_code == 200session_payload = session_response.get_json()assert session_payload["temporary_unrestricted_org_access"] is False- assert session_payload["capabilities"]["can_read_instance"] is False+ assert session_payload["capabilities"]["can_read_instance"] is True+ assert session_payload["capabilities"]["can_chat"] is Falseassert session_payload["capabilities"]["can_use_system"] is Falsediff --git a/vibe/authorization.py b/vibe/authorization.pyindex 7592d8e34..ab860da49 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -103,26 +103,31 @@ class AuthorizationContext:)def _has_admitted_remote_identity(self) -> bool:- """Return whether this context carries an identity accepted for runtime use.+ """Return whether identity-sensitive projections may trust this subject.- HTTP admission validates the signed session before a request reaches a- service. Services are also callable directly, so they must not infer- authority from a caller-constructed ``owner`` role alone. Show Page- email grants are the one non-Organization remote identity and retain- their signed viewer/page scope.+ Runtime HTTP admission and ordinary role rank are evaluated separately.+ This predicate is reserved for projections such as ``is_instance_owner``+ that must not infer identity from a caller-constructed role alone. Show+ Page email grants retain their signed viewer/page scope."""if not self.is_remote:return Trueif self.instance_access_source == "show_page_email":return self.instance_role == "viewer" and bool(self.show_page_id)+ if self.instance_access_source == "email":+ # Email-grant sessions are scoped by the Show Page email access+ # boundary; their instance role rank governs non-page surfaces.+ return Truereturn self.is_active_organization_memberdef has_role(self, minimum_role: str) -> bool:if self.is_trusted_local:return True- if not self._has_admitted_remote_identity():- return False+ # The temporary Organization rollout intentionally has no per-surface+ # role split: an admitted active member may use any runtime surface.+ if has_temporary_unrestricted_org_access(self):+ return Truereturn _ROLE_RANK.get(self.instance_role or "", 0) >= _ROLE_RANK[minimum_role]@property@@ -373,15 +378,6 @@ def require_instance_role(if isinstance(context, AuthorizationContext)else context_from_session_payload(context))- # The temporary rollout intentionally has no per-surface role split for an- # active Organization member, but it does not turn an arbitrary remote- # Instance owner into an Organization member. Keep exact Show Page email- # grants on their signed viewer role; the HTTP/page boundary scopes them to- # the one page separately.- if resolved.is_remote and resolved.instance_access_source != "show_page_email":- if not has_temporary_unrestricted_org_access(resolved):- raise InstanceAuthorizationError(minimum_role)- return resolvedif not resolved.has_role(minimum_role):raise InstanceAuthorizationError(minimum_role)return resolveddiff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 7a238eb12..32ec84a43 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -2423,6 +2423,7 @@ def enforce_instance_role_capabilities():from vibe.authorization import (InstanceAuthorizationError,REMOTE_HTTP_ACTIVE_ORGANIZATION_MEMBER,+ REMOTE_HTTP_LOCAL_ONLY,has_temporary_unrestricted_org_access,http_authorization_policy,require_instance_role,@@ -2441,26 +2442,30 @@ def enforce_instance_role_capabilities():except (LookupError, RuntimeError):# This helper is also exercised by pure policy tests outside a request.context = None- if context is None:- return jsonify(- {- "ok": False,- "error": "instance_access_forbidden",- "required_role": minimum_role,- }- ), 403- # Known temporary runtime routes are admitted only for an active- # Organization member. Preserve the established remote-disabled response- # for other authenticated remote principals instead of leaking a role-only- # failure before the remote execution boundary can classify the request.- if (- context.is_remote- and policy.remote_access == REMOTE_HTTP_ACTIVE_ORGANIZATION_MEMBER- and request.path.startswith("/api/")- and not has_temporary_unrestricted_org_access(context)- ):- return _remote_execution_disabled_response()+ # Cloud-management routes re-establish identity themselves (OAuth handshake,+ # silent reauthorization). They must admit an authenticated remote principal+ # who is not yet an active Organization member, so they bypass the+ # Organization-admitted-identity role gate; each handler re-validates cloud+ # identity before acting.+ is_identity_bootstrap_path = request.path.startswith("/api/cloud-management/")+ if is_identity_bootstrap_path:+ return Nonetry:+ if context is None:+ raise InstanceAuthorizationError(minimum_role)+ if (+ context.is_remote+ and request.path.startswith("/api/")+ and not has_temporary_unrestricted_org_access(context)+ ):+ # Routes classified for the temporary rollout and existing+ # trusted-local routes retain the remote-execution error contract.+ # Ordinary remotely exposed runtime APIs instead fail the active+ # Organization membership admission check here, before role rank.+ if policy.remote_access == REMOTE_HTTP_ACTIVE_ORGANIZATION_MEMBER:+ return _remote_execution_disabled_response()+ if policy.remote_access != REMOTE_HTTP_LOCAL_ONLY:+ raise InstanceAuthorizationError(minimum_role)require_instance_role(context, minimum_role)except InstanceAuthorizationError:return jsonify(