a2ui-project / a2ui-project/a2ui

Some `updateDataModel` edge cases could do with some clarification

Đang mở
#1,499 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
component: specification P2 type: feature/enhancement
Ngôn ngữ chính
TypeScript
Star
16.4k
Fork
1.3k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
134

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.