-
Notifications
You must be signed in to change notification settings - Fork 138
chore(server): check task and context ownership for a2a proxy requests #1356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/beeai-server/src/beeai_server/domain/models/a2a_request.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from uuid import UUID | ||
|
|
||
| from pydantic import AwareDatetime, BaseModel | ||
|
|
||
|
|
||
| class A2ARequestTask(BaseModel): | ||
| task_id: str | ||
| created_by: UUID | ||
| provider_id: UUID | ||
| created_at: AwareDatetime | ||
| last_accessed_at: AwareDatetime |
24 changes: 24 additions & 0 deletions
24
apps/beeai-server/src/beeai_server/domain/repositories/a2a_request.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from datetime import timedelta | ||
| from typing import Protocol, runtime_checkable | ||
| from uuid import UUID | ||
|
|
||
| from beeai_server.domain.models.a2a_request import A2ARequestTask | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class IA2ARequestRepository(Protocol): | ||
| async def track_request_ids_ownership( | ||
| self, | ||
| user_id: UUID, | ||
| provider_id: UUID, | ||
| task_id: str | None = None, | ||
| context_id: str | None = None, | ||
| allow_task_creation: bool = False, | ||
| ) -> None: ... | ||
|
|
||
| async def get_task(self, *, task_id: str, user_id: UUID) -> A2ARequestTask: ... | ||
|
|
||
| async def delete_tasks(self, *, older_than: timedelta) -> int: ... | ||
| async def delete_contexts(self, *, older_than: timedelta) -> int: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.../src/beeai_server/infrastructure/persistence/migrations/alembic/versions/29762474b358_.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """add a2a request tracking tables | ||
|
|
||
| Revision ID: 29762474b358 | ||
| Revises: 28725d931ca5 | ||
| Create Date: 2025-10-20 09:44:21.015314 | ||
|
|
||
| """ | ||
|
|
||
| from collections.abc import Sequence | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "29762474b358" | ||
| down_revision: str | None = "28725d931ca5" | ||
| branch_labels: str | Sequence[str] | None = None | ||
| depends_on: str | Sequence[str] | None = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table( | ||
| "a2a_request_contexts", | ||
| sa.Column("context_id", sa.String(length=256), nullable=False), | ||
| sa.Column("created_by", sa.UUID(), nullable=False), | ||
| sa.Column("provider_id", sa.UUID(), nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.Column("last_accessed_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.PrimaryKeyConstraint("context_id"), | ||
| ) | ||
| op.create_table( | ||
| "a2a_request_tasks", | ||
| sa.Column("task_id", sa.String(length=256), nullable=False), | ||
| sa.Column("created_by", sa.UUID(), nullable=False), | ||
| sa.Column("provider_id", sa.UUID(), nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.Column("last_accessed_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.PrimaryKeyConstraint("task_id"), | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_table("a2a_request_tasks") | ||
| op.drop_table("a2a_request_contexts") | ||
| # ### end Alembic commands ### |
2 changes: 1 addition & 1 deletion
2
.../src/beeai_server/infrastructure/persistence/migrations/alembic/versions/46ec8881ac4c_.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
a2a_proxy_http_transport.__name__?