xihaian251 opened a new pull request, #1047:
URL: https://github.com/apache/burr/pull/1047
# PR Body — Preserve partition identity across HTTP and React
> Draft only. This work has not been pushed and no PR has been created.
## Title
```
fix(tracking-ui): preserve partition identity across HTTP and React
```
Base: `apache/burr:main` at `36e3ff3048c8cabd7aac6d5c373307934bf3c2df`
Patch: `PARTITION_UI_IDENTITY_FIX.patch`
SHA-256: `5cbfad0c81456413aa27fb516b083db1633a15b3c258f28d3bdd407990a3bdb5`
Scope: 12 files, +1080 / −94
---
## Summary
`partition_key` loses identity between the tracker, HTTP API and React UI:
- `run.py` maps the literal string `__none__` to Python `None` in path
parameters, making the two indistinguishable.
- Empty keys and keys containing `/` cannot be represented by the
single-segment path routes.
- The generated client uses `encodeURI` for path parameters, which leaves
`?`, `#` and `%` unescaped.
- `LocalBackend.list_apps(None)` means **no filter**, while the UI used
`__none__` as if it meant "only None".
- The legacy Annotation GET route still maps `__none__` to `None`; because
`get_annotations(partition_key=None)` means no filter, a literal `"__none__"`
query returned annotations from every partition.
- `AppList.tsx` used `app_id` alone as a React key and as the parent-map
key, so two runs with the same `app_id` but different partitions collide.
- Navigation used `|| 'null'` / `|| '__none__'`, collapsing `None`, `""`,
`"null"` and `"__none__"`.
- The initially added React routes `/project/:projectId/apps` and
`/project/:projectId/app/:appId` shadowed legacy partition keys `"apps"` and
`"app"`.
All of these were confirmed with real FastAPI `TestClient`, real
`LocalBackend` data and real React Router/Vitest tests.
## Change
1. Add unambiguous HTTP query endpoints while preserving all existing routes:
- `GET /api/v0/apps/{project_id}/list`
- `GET /api/v0/apps/{project_id}/{app_id}/detail`
- `POST /api/v0/apps/{project_id}/{app_id}/annotations/{sequence_id}`
- `GET /api/v0/apps/{project_id}/annotations`
- `none_partition` on the legacy Annotation GET route for compatibility
callers
2. Add matching generated-client methods; partition values travel as query
values and are encoded with `encodeURIComponent`.
3. Add `partitionIdentity.ts` with tagged composite keys, query arguments
and identity-preserving URL helpers.
4. Use composite `(app_id, partition_key)` keys in `AppList.tsx` and
`StepList.tsx`, including fork/spawn parent grouping.
5. Move identity-aware React routes to the reserved
`/partition-identity/...` prefix. Legacy paths such as `/project/p/apps` and
`/project/p/app/a` again resolve to partition keys `"apps"` and `"app"`.
6. Use the exact Annotation query endpoint in `AppView.tsx` and
`StepList.tsx`; the global Annotation view keeps the legacy no-filter endpoint.
## Compatibility
- All old HTTP routes and their behavior are retained.
- The legacy Annotation GET route keeps its historical sentinel mapping and
no-filter behavior when no partition is supplied; it is not used for
identity-sensitive reads by this UI patch.
- All old React paths are retained, including legal partition keys named
`apps` and `app`.
- Legacy AppList path `/project/p/null` keeps main's behavior: `"null"` is
queried as a literal partition string. Legacy `/project/p/__none__` keeps the
historical no-filter behavior. New routes express the None partition only
through `none_partition=true`.
- No storage format change; #1046 remains the owner of partitioned storage
paths.
- No SQLite / InMemory persister change and no migration.
- Query semantics for the new identity-safe endpoints:
- list with neither parameter: no partition filter;
- `none_partition=true`: only `partition_key is None`;
- `partition_key=`: empty-string partition;
- `partition_key=__none__`: literal string `"__none__"`;
- `partition_key=null`: literal string `"null"`;
- mutually exclusive `partition_key` / `none_partition`: HTTP 400.
- Annotation GET requires an explicit identity; unfiltered global queries
remain available through the legacy endpoint.
- 404 means no data; 400 means ambiguous or missing identity.
## Relationship to #1046
This patch applies cleanly to `main` and to #1046's HEAD
(`2855635eaecdcf7ebd7ddddc994d26cd17c94baf`). On main, legacy storage still
collapses two partitions sharing an `app_id`; that is #1046's scope. With #1046
applied, the new query routes and React composite keys return and display
separate states for `shared`/A and `shared`/B. This PR does not modify or
duplicate #1046.
## Validation
- Python 3.10, 3.11, 3.12 and 3.13: 10 HTTP identity/Annotation/pagination
tests pass on each.
- `tests/tracking`: 29 passed, 1 skipped on this patch; stacked with #1046:
47 passed, 1 skipped.
- Frontend: TypeScript clean; Vitest 15/15 including real request-parameter
regression tests for legacy `"null"`, legacy `__none__` and new
`none_partition=true`; Vite build succeeds; ESLint on changed files clean.
- Real Annotation negative control confirms the legacy route returns all
five partitions for `partition_key=__none__`; the new route returns only the
literal `__none__` annotation.
- Explicit-None pagination test uses 150 None apps plus 50 non-None apps and
verifies page contents, total, offsets and `has_another_page`.
- Hosted CI has not run; all results are local.
Relates to #319. This PR is the HTTP/UI identity layer; #1046 is the storage
layer.
--
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]