amoghrajesh opened a new pull request, #67902:
URL: https://github.com/apache/airflow/pull/67902
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull
request.
Write a good git commit message following this guide:
http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the
documentation.
Feel free to ping (in general) for the review if you do not see reaction for
a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we
sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change below checkbox to `[X]` followed by the name of the tool, uncomment
the "Generated-by".
-->
- [x] Yes: claude sonnet 4.6
<!--
Generated-by: [Tool Name] following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
related to UI PR: https://github.com/apache/airflow/pull/67292
### What problem are we solving?
Asset store entries can be written by any task, but there was no way to know
which task instance made the last write. This makes it impossible to link a
stored value back to the run that produced it — a gap for UI attribution and
auditability.
### Current behaviour
The `asset_store` table has no record of the writing task instance. All
writes are anonymous: the value and timestamp are stored, but there is no way
to trace which task instance was responsible.
### How this helps
- **Debugging**: when a watermark or checkpoint value looks wrong, you can
immediately see which DAG run wrote it — without digging through logs or
correlating timestamps manually.
- **Auditability**: external tooling (governance, lineage, monitoring) can
consume the `last_updated_by` fields to build a provenance trail from stored
value back to the producing run.
- **UI linkage**: the `dag_id`, `run_id`, `task_id`, and `map_index` fields
are exactly what the Grid view needs to deep-link from an asset store entry to
the task instance that wrote it (follow-up UI work).
### Proposed change
Adds a `last_updated_by_ti_id` column (`UUID`, FK → `task_instance.id`, `ON
DELETE SET NULL`) to `asset_store`.
The Execution API PUT endpoints extract the task instance UUID from the JWT
token and record it on every write.
The Core API list and get endpoints resolve this to human readable
identifiers via a LEFT JOIN on `task_instance`, returning a `last_updated_by`
object with `dag_id`, `run_id`, `task_id`, and `map_index`. `last_updated_by`
is `null` when the entry has never been written by a task (e.g. seeded via the
Core API directly) or when the writing task instance has since been deleted.
### Design decisions worth flagging
1. **Why LEFT JOIN rather than a separate lookup:** a separate
`session.get(TaskInstance, ti_id)` per row would cause N+1 queries on the list
endpoint. The LEFT JOIN (not INNER) is required because `last_updated_by_ti_id`
is nullable — an INNER JOIN would silently drop entries that were never written
by a task.
2. **Why `set_asset_store` lives on `MetastoreStoreBackend`, not
`BaseStoreBackend`:** tying a write to a task instance UUID is a database
centric / specific concern and it only makes sense when the backend has a
`task_instance` table to reference. Adding `ti_id` to the base interface would
force every alternative backend (Redis, S3, etc.) to implement a concept that
has no meaning for them. Instead, `MetastoreStoreBackend` gets dedicated
`set_asset_store` /`aset_asset_store` methods, and the Execution API routes
dispatch to them via `isinstance` check, falling back to the generic `set()`
for other backends.
### Example response
```json
{
"asset_store": [
{
"key": "last_run_summary",
"value": {
"rows_loaded": 4790,
"prev_watermark": "2026-01-01T00:00:00+00:00",
"completed_at": "2026-06-02T13:59:04.341208+00:00"
},
"updated_at": "2026-06-02T13:59:04.371604Z",
"last_updated_by": {
"dag_id": "example_asset_store_producer",
"run_id": "manual__2026-06-02T13:58:59.253826+00:00",
"task_id": "load",
"map_index": -1
}
},
{
"key": "total_runs",
"value": 1,
"updated_at": "2026-06-02T13:59:04.363092Z",
"last_updated_by": {
"dag_id": "example_asset_store_producer",
"run_id": "manual__2026-06-02T13:58:59.253826+00:00",
"task_id": "load",
"map_index": -1
}
},
{
"key": "watermark",
"value": "2026-06-02T13:59:04.341208+00:00",
"updated_at": "2026-06-02T13:59:04.346110Z",
"last_updated_by": {
"dag_id": "example_asset_store_producer",
"run_id": "manual__2026-06-02T13:58:59.253826+00:00",
"task_id": "load",
"map_index": -1
}
}
],
"total_entries": 3
}
```
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]