a2ui-project / a2ui-project/a2ui

Some `updateDataModel` edge cases could do with some clarification

Ouverte
#1,499 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
component: specification P2 type: feature/enhancement
Langage dominant
TypeScript
Étoiles
16.4k
Forks
1.3k
Merge moyen
2 j 13 h
PR mergées (30 j)
134

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Read the specification file at specification/v0_9/json/server_to_client.json and the renderer_guide.md. Examine the web_core implementation in data-model.ts and compare with the Flutter genui package's behavior for the edge cases listed. The goal is to propose clarifications for the updateDataModel operation, focusing on out-of-bounds list sets and error handling for type-incorrect paths.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
dart, typescript
Domaine
documentation
Type d'issue
Documentation
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
55/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.