Repository navigation
Description
Context
The Dagger API exposes your workspace as a graph of typed values. You can also view its artifacts as rows in a table. Each column is a dimension. An artifact's value in a dimension is a coordinate. This mapping is called artifact flattening. You use it to filter, group, and address artifacts, for example with dagger check --go-module=..
Problem
1. The result is too complex
Tables have too many columns. Names show internal details. Edge cases give unexpected results. For example, a Docker Compose service gets these coordinates:
| Dimension | Coordinate |
|---|---|
module |
docker |
/docker/compose/projects |
e2e |
/docker/compose/projects/services |
web |
type:Service |
docker/compose/projects/services/up |
2. The rules are not rigorous
The model was designed, but some rules were not specified. They were added case by case across discovery, the engine, and the CLI. Some of the result is AI slop. There is no standalone specification or implementation, so the rules are difficult to test or improve.
Some rules are incorrect. If a collection's items are also collections, both levels get the same dimension. One column then holds two keys.
Solution
Implemented in #15177.
- Move the rules into a standalone Go package,
core/artifact/flattening. It maps the complete schema to dimensions, and each artifact to coordinates. It runs without an engine. - Specify the rules. Dimensions depend only on the schema, not on filters or collection contents.
- Replace path-based dimensions with three types of dimension:
| Dimension | Coordinate | Example |
|---|---|---|
module |
Module name | module=docker |
| One for each collection type. The identifier is the type name. The label is the item type in kebab-case. | Key of the item | docker-compose-service=web |
name |
Field path from the nearest collection item, or from the module root | name=up, name=python310.unit |
The Docker Compose service from the example above gets these coordinates:
| Dimension | Coordinate |
|---|---|
module |
docker |
docker-compose-project |
e2e |
docker-compose-service |
web |
name |
up |
Answers to the open questions
- Two checks on the same parent have different
namecoordinates, for examplepython310.unitandpython310.slow. - Nested collections get one dimension for each collection type. A path that repeats the same collection type is rejected.
- One collection type on two or more field routes in the same scope. A scope is a module root or a collection item. The keys of that type get the route as a prefix. For
before: Testsandafter: Testswith keyunit, the coordinates aretest=before.unitandtest=after.unit. In all other cases the key is the author's key.
Activity
[-]Define artifact flattening[/-][+]Isolate and improve artifact flattening[/+]