bobbai00 opened a new issue, #9483:
URL: https://github.com/apache/texera/issues/9483
### Task Summary
This issue carries out the proposal in #9395. Texera manages six kinds of
resources: workflows, datasets, models, computing units, environments and
warehouses. Each kind was built on its own, with its own tables, its own
endpoints in its own service, its own versions and its own access rules. So the
same three things are implemented once per kind: creating, reading, updating
and deleting a resource, keeping its versions, and deciding who may access it.
This refactor builds those parts once, as shared code over a shared schema, and
describes the API in one contract from which the code on both sides is
generated.
#### Before
Each service carries its own resource code, and each kind has its own tables.
```mermaid
flowchart LR
fe["Angular frontend"]
ag["Agent service"]
subgraph services["Each service has its own resource code"]
ds["Dashboard Service<br/>workflows, warehouses"]
fs["File Service<br/>datasets, models"]
cs["Computing Unit Managing Service<br/>computing units"]
cu["Computing unit<br/>environments"]
end
subgraph tables["Each kind has its own tables"]
t1[("workflow,
workflow_of_user,<br/>workflow_user_access,<br/>workflow_version")]
t5[("user_warehouse")]
t2[("dataset, model,<br/>dataset_user_access,
model_user_access,<br/>dataset_version, model_version")]
t3[("workflow_computing_unit,<br/>computing_unit_user_access")]
t4[("virtual_environments")]
end
fe --> ds
fe --> fs
fe --> cs
fe --> cu
ag --> ds
ds --> t1
ds --> t5
fs --> t2
cs --> t3
cu --> t4
```
#### After
Every kind goes through the same generated interfaces and the same shared
code.
```mermaid
flowchart LR
api["api/<br/>one contract"]
fe["Frontend"]
ag["Agent service, MCP"]
cl["Generated client"]
subgraph services["Each service implements the interfaces generated from
api/"]
k1["Workflows, warehouses,<br/>environments"]
k2["Datasets, models"]
k3["Computing units"]
end
sh["Shared code<br/>resources, versions,<br/>access, lineage"]
db[("resource, resource_version,<br/>access, lineage,<br/>tables for
kinds<br/>that need one")]
api -. "generates" .-> cl
fe --> cl
ag --> cl
cl --> k1
cl --> k2
cl --> k3
k1 --> sh
k2 --> sh
k3 --> sh
sh --> db
```
The shared code stands on four common tables: `resource`,
`resource_version`, `access` and `lineage`. A kind whose own fields need SQL
keeps a table of its own, and an execution ties a workflow version to the
computing unit and the warehouse it used.
```mermaid
erDiagram
user ||--o{ access : "holds"
resource ||--o{ access : "grants"
user ||--o{ resource : "creates"
resource ||--o{ resource_version : "has"
resource_version ||--o{ lineage : "version"
resource_version ||--o{ lineage : "source"
resource ||--o| workflow : "kind fields"
resource ||--o| computing_unit : "kind fields"
resource ||--o| warehouse : "kind fields"
resource_version ||--o| workflow_version : "content"
user ||--o{ execution : "starts"
workflow_version ||--o{ execution : "executed as"
computing_unit ||--o{ execution : "executes"
warehouse ||--o{ execution : "stores"
resource {
uuid rid PK
string kind
string name
json spec
}
resource_version {
uuid rid PK
int vno PK
string content_ref
}
access {
uuid rid PK
int uid PK
string level
}
lineage {
uuid rid PK
int vno PK
uuid source_rid PK
int source_vno PK
string relation PK
}
```
#### Tasks
1. **Schema updates reach every deployment** (#9484). Most later tasks
change tables that deployments already hold, so each update must apply itself.
2. **One API contract** (#9485). The API is described once in `api/`, and
the server interfaces, the TypeScript client, the permission map and tool
definitions are generated from it.
3. **One token verifier** (#9486). Every service, the agent service
included, checks tokens by the same rules, implemented once per language.
4. **One id and one record per resource** (#9487). Every resource gets a
global `rid`, and `resource` and `resource_version` describe every kind, as
views over today's tables at first.
5. **One access check** (#9488). One `access` table and one function decide
who may read, write or own any resource, and every kind is shared the same way.
6. **Reads first** (#9489). Every kind is read through `GET /{kind}` and
`GET /{kind}/{rid}` before any write changes.
7. **Writes, one kind at a time** (#9490). Each kind's writes and versions
move onto the shared code, with its old routes kept as adapters.
8. **Lineage** (#9491). One table records which versions a version uses and
which version it was derived from.
9. **Cleanup** (#9492). The old routes and tables go once nothing uses them,
and old ids survive only as a mapping to `rid`.
#9484, #9485 and #9486 can start now and in parallel, except the amber part
of #9486, which waits for #5423 to move amber to Dropwizard 4. The rest follow
in this order:
```mermaid
flowchart TB
subgraph now["Can start now, in parallel"]
A["#9484<br/>Schema updates"]
B["#9485<br/>One contract"]
C["#9486<br/>One verifier"]
end
X["#5423<br/>Dropwizard 4 in amber"]
D["#9487<br/>One id, one record"]
E["#9488<br/>One access check"]
F["#9489<br/>Reads"]
G["#9490<br/>Writes, kind by kind"]
H["#9491<br/>Lineage"]
I["#9492<br/>Cleanup"]
A --> D
D --> E
B --> E
X -.-> C
X -.-> E
E --> F
F --> G
G --> H
G --> I
```
#### Out Of Scope
- New kinds come after the shared code exists, each in its own issue:
conversations, so that the agent's chats can be saved with an owner (#5267 and
#5268, which #9453 moved to #9395), and operators (#9362).
- The agent's tools and the Texera MCP server stay in #9453 and #9457. What
this effort gives them is the contract: #9485 generates tool definitions from
it, so the MCP server can serve resource tools without writing them by hand.
- The React frontend (#9387) builds on the generated client. This refactor
changes no screen.
- Reading execution results without a computing unit is #8995.
#### Discussion Points
1. **The language of the shared code.** I propose Scala, so that the
services that stay on the JVM call the shared code in process, and the legacy
routes can call it directly. Go was suggested in #9395. The contract keeps a Go
server possible later, without changing the schema or the clients.
2. **In place, not a new codebase.** My Texera 2.0 prototype, built outside
main, rebuilt these layers in a separate codebase. This plan changes main in
small steps instead, each reviewed, tested and released on its own, while the
frontend and the agent service keep working.
3. **Where the kinds in amber are served.** Datasets and models stay in
file-service, and computing units in the Computing Unit Managing Service.
Workflows and warehouses are served by the Dashboard Service and environments
by the computing unit, both on Dropwizard 1.3, so their unified endpoints need
a Dropwizard 4 host: amber after #5423, or a new service for resource
endpoints. This has to be settled before the sharing endpoints of #9488 and the
reads of #9489.
4. **The other decisions that shape the rest.** Each task lists its own
discussion points. Besides the host, the ones that shape the later tasks are
what a `rid` is (#9487) and the access levels (#9488).
Done when all six kinds are created, read and shared, and the versioned ones
versioned, through one set of endpoints, decided by one access check, and
stored in one schema.
### Task Type
- [x] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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]