Skip to content

Resume in the right worktree, never against somebody else’s task

Find the handover that belongs to this worktree and branch, and see a task record from another checkout reported as foreign rather than enforced here.

guaranteed Sessions and handoverintermediateagentwrites state

Situation

Two checkouts of one repository, two workers. A task record that travels with a branch into a worktree that never claimed it would hold the wrong person to the wrong scope, and a handover from another branch offered as the one to resume from would send the next worker down the wrong path.

What you run

  • handover --resolve: the most relevant prior handover for this worktree and branch, or a clear absence
  • check: refuses to evaluate a task this checkout does not own
  • context: this worktree’s own identity, with no task borrowed from elsewhere

Scenario

setup: two-worktrees
given:
  - 'installed and wired, with a second worktree on another branch holding an active task scoped to lib'
steps:
  - id: nothing-here
    run: ['handover', '--resolve']
    note: 'no handover was written for this worktree and branch; absence is reported, never a record from elsewhere'
    expect:
      exit: 0
      stdout_contains: ['No relevant handover']
  - id: not-my-task
    run: ['check']
    note: 'the other worktree’s task is not this checkout’s; check reports no active task here instead of holding this checkout to a scope it never claimed'
    expect:
      exit: 12
      stdout_contains: ['no active task']
  - id: read-only-view
    run: ['context']
    note: 'what this worktree knows: its own git identity and no task'
    expect:
      exit: 0
      stdout_contains: ['^## GIT', 'none active']
then:
  - 'handover --resolve never offered a record from another branch'
  - 'check did not enforce the other worktree’s scope here'
  - 'local state under .ai/local/ is this checkout’s own and untracked'

Outcome

Records are resolved by worktree and branch. What another checkout is doing is visible through overlap, not enforced here, and nothing under .ai/local/ is shared through git.

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

  • installed and wired, with a second worktree on another branch holding an active task scoped to lib

when

  1. 1majordomus handover --resolve
  2. 2majordomus check
  3. 3majordomus context

then

  • handover --resolve never offered a record from another branch
  • check did not enforce the other worktree’s scope here
  • local state under .ai/local/ is this checkout’s own and untracked

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. no handover was written for this worktree and branch; absence is reported, never a record from elsewhere

    No relevant handover.
    • exit 0
    • stdout_contains /No relevant handover/
  2. the other worktree’s task is not this checkout’s; check reports no active task here instead of holding this checkout to a scope it never claimed

    majordomus: no active task (.ai/local/state/current.yaml); run: majordomus start
    • exit 12
    • stdout_contains /no active task/
  3. what this worktree knows: its own git identity and no task

    # Majordomus context — <time>
    # a projection of durable state, not a source of truth: validate every line against git
    
    ## GIT
    repository   <repo>
    branch       main
    head         <sha>
    working_tree clean
    
    ## TASK
    none active — run: majordomus start "<task>" --scope <paths>
    
    ## KNOWLEDGE (candidates awaiting review on this branch; majordomus knowledge candidates)
    No knowledge candidates await review on this branch. That is an answer, not a gap: `majordomus knowledge candidates` lists every branch.
    
    ## EXCLUDED
    - context documents — no active task names a scope; run: majordomus context resolve <path>
    - handover — no record for this worktree and branch — absence, not a stale match
    
    ## BUDGET
    21 of 300 lines
    • exit 0
    • stdout_contains /^## GIT/
    • stdout_contains /none active/

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.