You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(server): implement resource scoping for tasks and push notifications
Introduces caller indentity isolation to ensure clients only access authorized resources, as mandated by the A2A spec.
- Add 'owner' field to `TaskMixin` and `PushNotificationConfig` database models.
- Add 'last_updated' field to `TaskMixin` for optimized sorting and indexing.
- Update `DatabaseTaskStore`, `InMemoryTaskStore` and `DatabasePushNotificationConfigStore` to use `OwnerResolver`.
- Add relevant Unit tests.
- Add Alembic configuration to enable users to update their own databases with non-optional `owner` field in `tasks` table.
This directory contains database migration scripts for the A2A SDK, managed by [Alembic](https://alembic.sqlalchemy.org/).
4
+
5
+
## Configuration
6
+
7
+
- `alembic.ini`: Global configuration for Alembic, including the database URL.
8
+
- `env.py`: Python script that runs when the Alembic environment is invoked. It configures the SQLAlchemy engine and connects it to the migration context.
All commands should be run from the project root using `uv run`.
14
+
15
+
### Viewing Status
16
+
```bash
17
+
# View current migration version of the database
18
+
uv run alembic current
19
+
20
+
# View migration history
21
+
uv run alembic history --verbose
22
+
```
23
+
24
+
### Running Migrations
25
+
```bash
26
+
# Upgrade to the latest version
27
+
uv run alembic upgrade head
28
+
29
+
# Downgrade by one version
30
+
uv run alembic downgrade base
31
+
```
32
+
33
+
### Creating Migrations
34
+
```bash
35
+
# Create a new migration manually
36
+
uv run alembic revision -m "description of changes"
37
+
38
+
# Create a new migration automatically (detects changes in models.py)
39
+
uv run alembic revision --autogenerate -m "description of changes"
40
+
```
41
+
42
+
## Troubleshooting
43
+
44
+
### "duplicate column name" error
45
+
If you see an error like `sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: owner`, it usually means the column was already created (perhaps by `Base.metadata.create_all()` in tests or development) but Alembic doesn't know about it yet.
46
+
47
+
To fix this, "stamp" the database to tell Alembic it is already at the latest version:
48
+
```bash
49
+
uv run alembic stamp head
50
+
```
51
+
52
+
## How to add a new migration
53
+
1. Modify the models in `src/a2a/server/models.py`.
54
+
2. Run `uv run alembic revision --autogenerate -m "Add new field to Task"`.
55
+
3. Review the generated script in `alembic/versions/`.
56
+
4. Apply the migration with `uv run alembic upgrade head`.
0 commit comments