from __future__ import annotations from agent.dashboard.agent_overrides import profile_author_prs_as_user from agent.utils.authorship import OPEN_SWE_BOT_EMAIL, OPEN_SWE_BOT_NAME from agent.utils.github_org_membership import INTERNAL_BOT_LOGINS def test_author_prs_as_user_defaults_off() -> None: # Default is the app bot; the per-user opt-in must be explicit. assert profile_author_prs_as_user(None) is False assert profile_author_prs_as_user({}) is False assert profile_author_prs_as_user({"author_prs_as_user": "true"}) is False assert profile_author_prs_as_user({"author_prs_as_user": True}) is True def test_commit_identity_is_the_app_bot() -> None: assert OPEN_SWE_BOT_NAME == "seahaven-openswe[bot]" assert OPEN_SWE_BOT_EMAIL == "296972425+seahaven-openswe[bot]@users.noreply.github.com" def test_self_trigger_guard_recognizes_our_app_bot() -> None: # Bot-authored PRs/actions must be recognized as our own to avoid self-trigger loops. assert "seahaven-openswe[bot]" in INTERNAL_BOT_LOGINS def test_default_commit_identity_in_prompt_is_the_app_bot() -> None: # SH-IDSPLIT-01: with no triggering-user identity (the default-bot path), the # constructed prompt must set the git commit identity to the app bot — so # commits, push, and PR all come in as the app (not the triggering user). from agent.prompt import construct_system_prompt prompt = construct_system_prompt(working_dir="/workspace", triggering_user_identity=None) assert OPEN_SWE_BOT_NAME in prompt assert OPEN_SWE_BOT_EMAIL in prompt