a2ui-project / a2ui-project/a2ui

Some `updateDataModel` edge cases could do with some clarification

Abierto
#1,499 2 comentarios 0 reacciones 0 asignados Ver en GitHub
component: specification P2 type: feature/enhancement
Lenguaje dominante
TypeScript
Estrellas
16.4k
Forks
1.3k
Merge medio
2 d 13 h
PR fusionados (30 d)
134

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.