Repository navigation
Description
Context
A collection is a module type that holds items with unique keys. The engine adds four engine operations to every collection: keys, list, get, and subset. The module author can also add custom functions. For example, VitestTestFiles.test runs the selected test files in one Vitest process.
#14802 made two changes:
- It removed batch planning from the engine. Before this change, when you selected several items,
dagger checkcalled the custom function of the same name once, instead of the item check once per item. Nowdagger checkruns each item check. Modules beforev1.0.0-beta.22keep the old behavior. - It removed the
batchnamespace. Custom functions moved next to the engine operations:
Before After
VitestTestFiles VitestTestFiles
├── keys, list, get, subset ├── keys, list, get, subset
└── batch └── test
└── test
The first change makes batching a module implementation detail. The second change was not necessary for the first. It only changed the call path from .batch.test(ws) to .test(ws).
Problem
Custom functions and engine operations now share one namespace. This causes three problems:
- Every collection reserves the names
keys,list,get, andsubset. A custom function with one of these names stops the module from loading:collection "Foo" function "list" conflicts with a collection operation. - Each new engine operation is a breaking change. It stops every module that already has a custom function with that name from loading.
- Callers of
.batchbreak. For example, the e2e module ofdagger/vitestfails withfield "batch" not found(feat: replace baseImageAddress with baseImage (Container) vitest#28).
Possible solutions
A. Hide custom functions. Remove custom functions from the API, so that collections expose only engine operations. A module that wants a bulk operation puts it on a regular object, for example a new function VitestProject.runFiles(ws, files).
B. Restore one namespace. Put custom functions back under one field. The field can be batch, or a name that does not refer to batching.
| A. Hide | B. Namespace | |
|---|---|---|
| Name conflict | Removed | Removed |
| Custom functions in the API | Removed | Kept, under one field |
One-call path subset(...).test(ws) and delta |
Removed | Kept |
| Breaking change for | Modules that expose custom functions | Callers of .test(ws) |
Legacy batch planning (before v1.0.0-beta.22) |
Needs internal access to custom functions | No change |
Acceptance criteria
- A collection can have a custom function with any name.
- A new engine operation does not break existing modules.
Activity