Skip to content

Run several workers in one repository without them colliding

Give each worker a declared scope, and find out immediately when two of them claim the same paths.

guaranteed Parallel workersintermediateagentoperatorwrites state

Situation

Two agents work the same repository at the same time. Each is individually reasonable; together they edit the same file from different assumptions, and the conflict surfaces as a merge, long after the decision that caused it.

What you run

  • start: takes the paths this task may touch, and refuses a second active task in one checkout
  • check: --overlap reports other worktrees whose claims intersect yours
  • finish: refuses to accept work outside the claimed paths

Scenario

setup: two-worktrees
given:
  - 'a second worktree of the same repository with an active task scoped to lib'
steps:
  - id: claim-a-scope
    run: ['start', 'narrow the parser', '--scope', 'lib']
    note: 'the task starts, and the overlap with the other worktree is reported'
    expect:
      exit: 0
      stdout_contains: ['^started t-', 'overlap']
  - id: see-the-overlap
    run: ['check', '--overlap']
    note: 'scope containment against every other worktree, never blocking'
    expect:
      exit: 0
      stdout_contains: ['overlap']
  - id: nothing-to-refuse
    run: ['finish', '--check']
    note: 'no file outside the claimed scope has been touched'
    expect:
      exit: 0
      stdout_contains: ['0 failing']
then:
  - 'two workers on one repository see each other by scope, and the second is told before it starts'

Outcome

Overlap is reported when the task starts rather than when the branches merge, and a task record belonging to another checkout is reported as foreign rather than enforced against yours.

The scenario

Executed against the real tool, in a repository prepared by two-worktrees, every time this site is generated. What follows is not a description of what should happen; it is what happened.

given

  • a second worktree of the same repository with an active task scoped to lib

when

  1. 1majordomus start narrow the parser --scope lib
  2. 2majordomus check --overlap
  3. 3majordomus finish --check

then

  • two workers on one repository see each other by scope, and the second is told before it starts

What the tool did

Evidence of the run this page was generated from: pass, 3 step(s). Output is normalised: the repository's path, timestamps, ids and durations are placeholders; nothing else is edited.

Tested by test/cases/94_use_cases.sh, which runs every scenario and refuses a step whose recorded output is not what it produced.

  1. the task starts, and the overlap with the other worktree is reported

    started t-<id>  profile=implementation  scope=lib
    INFO overlap     repo-other — claims lib — contains your lib  [reproduce: majordomus check --overlap]
    next: majordomus context; checkpoint every 15m; majordomus check before claiming anything
    • exit 0
    • stdout_contains /^started t-/
    • stdout_contains /overlap/
  2. scope containment against every other worktree, never blocking

    INFO overlap     repo-other — claims lib — contains your lib  [reproduce: majordomus check --overlap]
    INFO overlap     t-<id> — no other worktree claims an overlapping path
    • exit 0
    • stdout_contains /overlap/
  3. no file outside the claimed scope has been touched

    OK   knowledge   records — 0 record(s) valid against knowledge/v1; every reference resolves  [reproduce: majordomus knowledge check]
    ·    checkpoint  t-<id> — <timed against the checkpoint interval>
    OK   records     ledger.jsonl — every line is a well-formed event
    OK   blockers    t-<id> — none open
    OK   records     decisions.md — every entry is attributable
    OK   scope       t-<id> — 0 touched file(s), all within scope
    OK   state       t-<id> — exact (head <head>)
    INFO mesh        t-<id> — the repository declares no enabled mesh
    INFO use-case    30 advisory gap(s) — not covered by an active use case, and the policy does not require it: command:init command:update command:doctor command:watch command:start command:context command:checkpoint command:handover command:check command:finish command:history command:decision command:question command:prompt command:evidence command:skills command:capture command:search command:doctrine command:plan command:version command:session command:knowledge command:adr command:usecase command:rules command:migrate command:recover command:bench command:archive  [reproduce: majordomus usecase coverage]
    OK   use-case    0 of 30 target(s) covered — every public command the policy requires is named and run by an active use case (policy use_cases.coverage)
    INFO obligation  t-<id> — the task declares no obligations
    INFO gate        t-<id> — this repository declares no CI model at .ai/repo/ci/gates.yaml; nothing can be planned
    finish --check: 0 failing
    • exit 0
    • stdout_contains /0 failing/

Why the tool knows this

The chain from this page to the code: the use case names commands, rules and claims; each rule is dispatched from the registry and each claim names the test that proves it; the scenario above executed the commands. Nothing in this chain is prose about intent.

The rules that make it hold

Guarantees exercised

Related use cases

Computed from what they share: claims, rules, commands, category, applications. Nobody maintains this list.

The moments this answers

Searches the titles and descriptions of every page this site publishes.