Skip to content
refs

Give agent sessions a branch, and take work by task, pull or branch

Aman Kumarcommitted Oct 9, 20267436a59parent c000805

Push rights now come from the session's branch, not its task. A session holds one branch: tasks/<n> with a task, a pull request's head branch, or any branch it names. A session without a branch claims a new one by pushing it first. Agents see pull requests linked to their task or opened from their branch.

3 decisions

A decision record here could not be read. Line 8: expected "name: value" under rejected.

Branch names are free, except the default branch, tasks/ names, HEAD and names git rejects; a session without a branch claims a new one on its first push.

Why

  • Aman chose free branch names over an agent/<session>/<slug> prefix.
  • tasks/<n> stays bound to its task, so no session pushes a task branch without the task.

Assumes

  • The claim is safe because it is written only after the atomic create landed, which fails for an existing branch.

Touches

  • wire.ts
  • index.ts

refs_take takes exactly one of task, pull or branch; a pull request brings its task only when its head is that task's branch.

Why

  • Agents must be able to work on a pull request or branch that has no task.

Touches

  • sessions.ts
  • mcp.ts

An agent may see and open pull requests linked to its task or whose head is its branch.

Why

  • An agent on a branch without a task must reach the pull request it works on.

Touches

  • policy.ts
15 files changed · +214 −72
apps/backend/analytics.ts+2 −1
apps/backend/auth.ts+3 −1
apps/backend/contract/events.ts+1 −1
apps/backend/identity.ts+2 −3
apps/backend/index.ts+16 −7
apps/backend/mcp.ts+12 −5
apps/backend/mentions.ts+2 −1
apps/backend/policy.ts+12 −3
apps/backend/sessions.ts+51 −20
apps/backend/test/sessions.test.ts+53 −2
apps/frontend/routes/llms-txt.ts+5 −5
docs/ref-protocol.md+12 −12
migrations/0029_session_branches.sql+3 −0
packages/protocol/test/wire.test.ts+18 −6
packages/protocol/wire.ts+22 −5