Records Architecture decision

ADR-102

Order Workspace Tasks with Turborepo

Accepted Decided 2026-09-21 Source file
Updated
2026-10-18

Context

Root scripts and mise tasks repeat the order in which shared TypeScript packages must build. Adding a consumer requires several script changes. Repeated checks compile the same dependencies again.

Decision

Use Turborepo for JavaScript workspace task ordering. Root scripts select a task and package; dependsOn: ["^build"] builds its workspace dependencies first. Package scripts remain local commands. pnpm owns dependency installation. mise owns tool versions, Go tasks, native packaging, and supervised services. Authling retains its independent workspace and tasks.

Make the local Runling bot an explicit workspace package. Keep its Runling, Chatto client, and HTTP dependencies there, rather than at the root: Turbo includes root workspace dependencies in every task's cache key. The bot has a test script but no check or lint script. Its empty check and lint task definitions prevent Turbo's virtual tasks from building the Runling console during unrelated workspace checks.

The API types, Translatto, and Chatto client packages have no build. Consumers read their TypeScript source (ADR-116).

Cache the Chatto frontend and Runling builds. Changes to mise tool settings, the pnpm configuration file, or NODE_OPTIONS invalidate every cached task. The frontend build reads CHATTO_BUILD_VERSION and CHATTO_FRONTEND_PRECOMPRESS, so both are declared task environment inputs. Test, story, end-to-end, and documentation files are excluded from both task inputs. Turbo restores build/** and dist/** respectively. The Chatto mise build tasks declare their sources and output directories. The frontend task includes the source of its workspace libraries, and both the frontend build and embedded copy. Mise checks source content and complete output trees, so it skips unchanged tasks and restores missing files. This also works when Turbo restores files with timestamps older than the local sources. The frontend completion output includes the build version, compression setting, and NODE_OPTIONS in its name as a hash. Changes to these environment inputs also make mise run the task again. The frontend task runs embedding only when it must build or restore output.

Do not set cacheDir. Turbo then shares the local cache of the main checkout with every Git worktree, so a new worktree restores unchanged builds. The cached outputs contain no absolute worktree paths. Disable telemetry in the root pnpm turbo script.

The root script also sets TURBO_CACHE=local:rw when the caller does not set it. Local runs therefore use only the local cache, and no cache service receives source, build output, or logs. turbo.json enables remote caching only so that CI can select it. A package script that runs Turbo must use pnpm -w turbo; plain pnpm turbo in a package runs Turbo without the root script.

CI uses the GitHub Actions cache as the Turbo remote cache. The shared setup action starts rharkor/caching-for-turbo, pinned to a commit. The action runs a local cache server that stores one Actions cache entry for each task hash. Jobs on the same operating system share build and check results, and GitHub removes entries that are not used. Build output stays in the repository's Actions cache, with the Go and pnpm caches. Every CI run reads and writes entries, so the first job that builds a task shares the result with the other jobs of the same run. Entries from a pull request are visible only to runs of that pull request, and all runs can read entries from main. A run that builds every task writes about 16 MB. Jobs that publish images or releases turn the remote cache off, so published artifacts build from source.

Check tasks are cached. Lint and test tasks remain uncached. Use loose environment mode to retain existing release, test, and development settings. Keep publishing, signing, and installed-package tests outside Turbo.

Consequences

New consumers declare workspace dependencies in package.json instead of adding ordered build chains. Existing root script and mise task names remain available, except the package builds that ADR-116 removes. Frontend and Runling artifacts can be restored after their output folders are removed, also in a different worktree. A restored build takes approximately one second. A warm mise dev restart skips the frontend build, embedding, and Go build. Changes to frontend source, workspace libraries, build configuration, or output files make mise run the affected build tasks again. Root checks and tests keep one-task concurrency to bound memory use; do not run separate SvelteKit tasks concurrently in one checkout.

CI jobs that install frontend dependencies run a third-party action, pinned to a commit. If its cache server does not start, the job fails. CI check and build results are only as correct as the Turbo task inputs: a task that reads a file or environment variable outside its declared inputs can restore a stale result.

Use mise x -- pnpm turbo run check --filter=runling --dry=json to inspect the task graph. Use --force on a Turbo run to bypass cached results. Direct package commands that use Runling require its build. Commands that use only the internal Chatto packages need no build.

Records that name this record

Esc