a2ui-project / a2ui-project/a2ui

Some `updateDataModel` edge cases could do with some clarification

オープン
#1,499 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
component: specification P2 type: feature/enhancement
主要言語
TypeScript
スター
16.4k
フォーク
1.3k
平均マージ
2日 13時間
マージ済み PR(30日)
134

説明

Consider the following from the spec:

https://github.com/google/A2UI/blob/0e0375749bf8a940d57969d612e74f7221ad246e/specification/v0_9/json/server_to_client.json#L93-L98

This is sufficient for the map/object case but leaves other operations undefined. The result is that a set of renderers can conform to the spec while having different behavior. Later in this issue, I'll list some cases where `web_core` and the [Flutter `genui` package ](https://github.com/flutter/genui) produce different state for the same message. `genui` isn't moved into this repo yet, but I still use it here just as an example of how different renderers can conform to the spec with different behavior.

If we decide to specify this behavior, it might be sufficient to just do so in the [`renderer_guide.md`](https://github.com/google/A2UI/blob/main/specification/v0_9/docs/renderer_guide.md) . The spec json is arguably the _correct_ place to do so, but I am not sure we want to blow up the spec with a bunch of pedantic specification around edge cases that agents will probably naturally avoid. My main interest here is just to achieve conformity across all the A2UI rendering platforms.

### 1. Out-of-bounds list set

`{path: "/items/5", value: "x"}` on a list of length 2:

- web_core: JS assignment creates a sparse array (length 6, indices 2-4 undefined).
- genui: silent no-op for `index > length`; append for `index == length`.

The spec's "(or created)" doesn't define what creation means at an out-of-bounds index. As an aside, I wonder if we should discourage use of sparse lists as many languages don't natively support them.

### 2. Error handling on type-incorrect paths

This one is honestly very unlikely, but I did notice a divergence between web_core and the `genui` Dart package.

Two related cases:
- `set("/a/b", x)` when `/a` is a primitive (path collides with a leaf).
- `{path: "/items/foo"}` when `/items` is a list (non-numeric index into an array).

- web_core ([data-model.ts#L99-L117](https://github.com/google/A2UI/blob/9526ab2ec05549443aa592cab056940aa360b37d/renderers/web_core/src/v0_9/state/data-model.ts#L99-L117)): throws `A2uiDataError`.
- genui: no-op. no warning/error.

The spec doesn't say whether `updateDataModel` is allowed to fail. It probably should. However, it's not clear to me whether or not we should blow up the renderer guide with a bunch of text detailing every class of malformed payload that an agent _could_ emit.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。