Skip to content

fix(session): make worker branch namespace child-safe#309

Open
neversettle17-101 wants to merge 2 commits into
mainfrom
fix/session-branch-namespace
Open

fix(session): make worker branch namespace child-safe#309
neversettle17-101 wants to merge 2 commits into
mainfrom
fix/session-branch-namespace

Conversation

@neversettle17-101

Copy link
Copy Markdown
Collaborator

Fixes #308

Summary

  • Change default worker branches from ao/<session-id> to ao/<session-id>/root so sibling PR branches like ao/<session-id>/<topic> are valid Git refs.
  • Teach SCM PR attribution that a /root session branch also owns sibling branches under the same namespace.
  • Update worker branch instructions and CLI help text.

Root Cause

AO created the session root branch as ao/<session-id> while instructing agents to create additional PR branches as ao/<session-id>/<topic>. Git cannot create both refs because refs/heads/ao/<session-id> blocks refs/heads/ao/<session-id>/<topic>.

Tests

  • GOCACHE=/private/tmp/ao-go-build-cache go test ./internal/session_manager
  • GOCACHE=/private/tmp/ao-go-build-cache go test ./internal/observe/scm
  • GOCACHE=/private/tmp/ao-go-build-cache go test ./internal/cli -run 'TestSpawn'

@Pritom14

Pritom14 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

@neversettle17-101 can you check this edge case :

If two sessions in the same repo somehow end up with ao/p-1 (no suffix) AND ao/p-1/root, both claim the prefix ao/p-1 for sibling PRs and the longest-prefix tiebreak ties at length 6. The winner is then determined by iteration order of byRepo[repoKey] — nondeterministic. Realistic only if a user manually picks ao/<id> as a branch override while another defaulted session lives at ao/<id>/root.

@neversettle17-101

Copy link
Copy Markdown
Collaborator Author

On the ao/p-1 vs ao/p-1/root edge case: I do not think this will show up in many normal flows.

The ambiguous case requires all of these to exist in the same repo:

  • Session A stored branch: ao/p-1
  • Session B stored branch: ao/p-1/root
  • PR head branch: ao/p-1/something

That is unlikely because existing sessions from before this fix may have ao/p-1, but newly spawned sessions after the fix will get new IDs like ao/p-2/root, ao/p-3/root, etc. AO should not naturally create both ao/p-1 and ao/p-1/root for two different sessions. Also, if ao/p-1 still exists as a Git ref, creating ao/p-1/root usually fails at Git ref creation anyway.

The more realistic compatibility case is an old running session with session.branch = ao/p-1 trying to create ao/p-1/topic; Git will reject that because ao/p-1 already exists as a leaf ref. That affects only sessions spawned in the short window after multi-PR support landed and before this fix. Those sessions can finish their root PR, or any fallback PR can be manually claimed if needed.

So I would keep this PR simple and not add extra tie-break logic unless we see this ambiguity in real state or a reviewer wants the deterministic fallback explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AO session branch namespace blocks child PR branches

2 participants