AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
fix(delegation): resolve the What it may do viewer through the shared caller resolver (#477)
Rufus7189ce55f006
diff --git a/packages/core/openexecutive/api/routes/may_do.py b/packages/core/openexecutive/api/routes/may_do.pyindex 53a0c83d..bb392a4c 100644--- a/packages/core/openexecutive/api/routes/may_do.py+++ b/packages/core/openexecutive/api/routes/may_do.py@@ -58,19 +58,21 @@ class MayDoOut(BaseModel):def _viewer(request: Request) -> Any:- from openexecutive.people.store import find_person_by_email, find_principal_person+ """The person asking, through the app's one caller resolver+ (``chat._resolve_caller_person_id``), so this page knows people the same+ way every other page does; a deployment that maps a signed-in account to+ its person there is followed here too. A request that names no one only+ counts as the principal under local login."""+ from openexecutive.api.routes.chat import _resolve_caller_person_id+ from openexecutive.people.store import get_personfrom openexecutive.utils.deployment import is_local_loginwho = api_caller.caller(request)+ if not who.email and not (who.defaults_to_principal and is_local_login()):+ raise HTTPException(status_code=403, detail="Sign in to see what it may do.")try:- if who.email:- person = find_person_by_email(who.email)- elif who.defaults_to_principal and is_local_login():- person = find_principal_person()- else:- raise HTTPException(status_code=403, detail="Sign in to see what it may do.")- except HTTPException:- raise+ person_id = _resolve_caller_person_id(request)+ person = get_person(person_id) if person_id is not None else Noneexcept Exception as exc:logger.exception("may_do: caller lookup failed")raise HTTPException(status_code=503, detail="Couldn't read the People list.") from excdiff --git a/packages/core/tests/unit/test_may_do.py b/packages/core/tests/unit/test_may_do.pyindex a881fce6..b50e3f7e 100644--- a/packages/core/tests/unit/test_may_do.py+++ b/packages/core/tests/unit/test_may_do.py@@ -257,6 +257,19 @@ def test_the_owner_sees_all_three(client: TestClient, ids: dict[str, int]) -> Noassert body["paused"] is False+def test_it_knows_people_the_way_the_rest_of_the_app_does(+ client: TestClient, ids: dict[str, int], monkeypatch: pytest.MonkeyPatch+) -> None:+ # A deployment can map a signed-in account to its person in the shared+ # caller resolver; the page must follow that, not look the email up again.+ monkeypatch.setattr(+ "openexecutive.api.routes.chat._resolve_caller_person_id", lambda request: ids["principal"],+ )+ resp = client.get("/what-it-may-do", headers={"x-caller-email": "[email protected]"})+ assert resp.status_code == 200+ assert _section(resp.json(), "executive")["available"] is True++def test_a_teammate_sees_their_own_and_the_departments(client: TestClient, ids: dict[str, int]) -> None:body = client.get("/what-it-may-do", headers=TEAMMATE).json()assert _section(body, "as_you")["available"] is False