Repository navigation
Replies: 2 comments
|
Thanks for the detailed write-up. Your two-project run behaves as documented: a plain lock name is shared by every task on the machine, in any project, so #15710 makes lock names render templates, so a project can scope a name to itself. A filter keeps the name short: [tasks.w]
lock = "package-lock.json-{{ config_root | hash(len=8) }}"That gives It doesn't add the AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable. |
|
Implemented in #15710: feat(task): render templates in lock names |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Allow a named task lock to cover one checkout (a git worktree) or one repository, as well as the whole machine:
The problem
The
lockadded in 2026.11.0 works well, and it's exactly what we need when parallel tasks write the same file. But today a lock has only two scopes:lock = "name"is shared by every task on the machine that names it, in any project.lock = trueis shared by every worktree of the repository, keyed on git's common directory and the task's name.Neither gives a lock for each checkout. Yet that is the scope of most clashes between tasks: two tasks of one
mise run, or of two terminals in the same worktree, that write the same file of that worktree, such aspackage-lock.json, a generated file, or a cache inside the checkout. Another worktree has its own copy of that file, so it doesn't need to wait.With several agents or terminals working in separate worktrees of one repository, which is the case that the documentation of
locknames, the wider scope makes unrelated runs take turns:package-lock.jsonmakes every project on the machine wait for every other one.What I ran
With mise 2026.11.4 on Linux, I made two separate projects,
p1andp2, each with thismise.toml:I then ran
mise run win both at once, startingp20.2 s afterp1.p2started only afterp1ended, so the run took 4 s instead of 2 s. I expected the two to run together, because each project has its ownpackage-lock.json. The same happened withlock = "{{config_root}}/package-lock.json".A lock's name can't include the checkout as a workaround either. The name is used as written, so
lock = "{{config_root}}/package-lock.json"is one name everywhere. And a shared task definition, such as one that several projects include, can't hard-code a per-project name.Proposal
Accept a table form with a
scope:scope = "machine"is today's behaviour, and the default. A plain string keeps meaning this.scope = "repository"shares the lock among every worktree of the task's repository, aslock = truedoes, but under a name that other tasks can share too.scope = "checkout"shares the lock only within the checkout that holds the task's config: the worktree's top-level directory, or the config root outside git.As far as I can tell, this fits the existing code.
LockKey::this_taskalready finds the repository throughrepository_of. A scoped key would hash the scope's root together with the name into itsid, so sorting,MISE_TASK_LOCKS, the nested-order check and the holder messages would all work unchanged. The message could saypackage-lock.json (this checkout), aslock = truesays(this repository).Alternatives considered
{{config_root}}. That's smaller, but each project then builds a scope out of paths by hand, the names in messages and inMISE_TASK_LOCKSbecome long paths, and two spellings of one path would make two locks.Context
We share task definitions across many projects, and run parallel agents in separate worktrees with long test runs. We'd use a checkout-scoped lock for short writes of shared files, and keep long tasks lock-free.
AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.323.
All reactions