Skip to content

feat(acp): advertise session list/fork, fix inference_speed category - #275

Merged
dirac-run merged 4 commits into
dirac-run:masterfrom
alexdim:dev/acp-zed-gaps
Oct 24, 2026
Merged

dirac-run merged 4 commits into
dirac-run:masterfrom
alexdim:dev/acp-zed-gaps

Conversation

@alexdim

@alexdim alexdim commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Advertise sessionCapabilities.list and sessionCapabilities.fork in initialize(), and expose listSessions / resumeSession alongside unstable_listSessions / unstable_resumeSession so @agentclientprotocol/sdk wires session/list and session/resume over JSON-RPC.
  • Implement unstable_forkSession in DiracAgent/AcpAgent: fresh session + task UUIDs, task-dir and ACP-journal copy under DATA_DIR, isolated runtime config, sessionStates registration, modes/configOptions in response; no history replay (matches resume semantics).
  • Retain shared Dirac-managed worktree ownership across forked sessions (resolveSharedSessionWorktree, getWorktreeOwnerSessionIds, hasOtherSessionWorktreeOwners): physical worktree removal on session deletion or deleteAfterMerge integration runs only when no other session still owns the worktree, and integration rejects while any co-owning session has an active task.
  • Synchronize fork snapshot capture (runSynchronizedSessionOperation + withTaskHistoryInventoryLock): source status check, source state resolution, task-directory copy, taskHistory upsert, and ACP journal copy all run under per-session synchronization and a single inventory lock hold, serialized against prompt initialization and session deletion.
  • Recategorize inference_speed from model to model_config per ACP spec.
  • Remove duplicated input.hint (description text) from slash commands.

Verification

  • 126 tests across ACP/session test suites (including worktree fork-survival with uncommitted edits, prompt initializing before fork, prompt starting during copy, and source deletion during copy); check-types:generated, check:arch, lint all pass.
  • Live cli/dist/cli.mjs --acp stdio verification: worktree fork + source deletion survival + last-owner cleanup, plus session/prompt → session/fork → session/list → session/resume / session/load.
  • RCA + diagrams + test plan: dev/acp-zed-gaps/ISSUE_AND_RCA.md; review notes: CODE_SMELL_REVIEW.md.

User test (live Zed + cli/dist/cli.mjs --acp)

  • Session list — past threads and forked threads shown in agent-panel history, transcript loads
  • agent: fork thread — new thread forks with context, shared worktree and uncommitted edits survive source deletion
  • Inference Speed — separate default/standard/fast selector on anthropic
  • Slash commands — descriptions render once, no duplicated hint
  • Model selection (gemini) — works end-to-end

@dirac-run dirac-run left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: session forking has two runtime-safety blockers.

P1 — Deleting the source can delete the fork's workspace and uncommitted edits.

cli/src/agent/sessionHistory.ts:112–128 permits the source's working directory to become the fork's directory, and DiracAgent.ts:1527–1562 registers the fork without shared worktree ownership or an independent worktree. Create source session S with a Dirac-managed worktree W, fork S using cwd: W, make uncommitted edits in the fork, then delete S. deleteSessionResources (DiracAgent.ts:220–226) calls deleteWorktree(..., true), which executes git worktree remove --force W. The fork remains registered while its workspace and edits are deleted. This requires no concurrency.

Please allocate an independent worktree, retain shared ownership until all dependent sessions release it, or reject this configuration. Add a source-deletion/fork-survival regression including uncommitted changes.

P1 — Forking does not capture a consistent source snapshot.

At DiracAgent.ts:1480–1509, the Processing check is outside runSessionRuntimeMutation, and the mutation protects only source-state resolution. Its barrier is released before cloneForkedSessionArtifacts copies task files and the journal (sessionHistory.ts:187–209). A new source prompt can write during the copy. A prompt already awaiting initialization can also leave the session apparently idle long enough for the early check to pass, then set Processing before the queued fork reads state without rechecking it. The active-prompt queue serializes prompts, not forks. Files and journal can therefore represent different conversation states. The inventory lock also begins after the filesystem copy, leaving deletion uncoordinated with that copy.

Please check source status inside synchronization and protect the entire snapshot against prompt mutation and deletion. Add controlled interleaving regressions for a prompt initializing before fork, a prompt starting during copy, and source deletion during copy. The sequential fork test does not cover these conditions.

Static code review of head 6b4d1cf04b652ac61c6190f7e345ff88975b1393, reassessed after #252/#272/#273 merged into master 441c5766c0b6f57f6ec2f9abd0e3745709d603b5. No tests or builds were run. These are intrinsic lifecycle/data-safety blockers, not dependency-only or missing-CI objections.

Alexandros Salapatas added 3 commits October 20, 2026 16:36
- Advertise sessionCapabilities.list and fork in DiracAgent.initialize
- Implement DiracAgent.unstable_forkSession and AcpAgent.unstable_forkSession with isolated sessionId, task directory copy, and renumbered update journal
- Change inference_speed category from model to model_config
- Remove input.hint duplication in sendAvailableCommands
- Replace unsafe _meta cast with runtime isObject guard in copySessionUpdates
- Extract resolveForkSourceState, resolveForkSourceCwd, cloneForkedSessionArtifacts into sessionHistory.ts and registerForkedSession helper in DiracAgent.ts
- keep shared worktree until last owner deletes or integrates
- hold session barrier and history lock across fork snapshot
- expose listSessions and resumeSession for ACP SDK wire dispatch
@alexdim

alexdim commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto master (441c5766) and fixed in e0be9b81:

  • Shared worktree ownership (cli/src/acp/acp-session-worktrees.ts, cli/src/agent/DiracAgent.ts):
    • When forking a session whose resolved sourceCwd equals or is nested inside the source session's Dirac-managed worktree, captureForkSnapshot registers shared ownership of that worktree record for newSessionId (rolling it back if cloning or in-memory registration fails).
    • releaseOwnedSessionWorktree (used by deleteSessionResources) and integrateWorktree (deleteAfterMerge) only remove the physical worktree on disk when !hasOtherSessionWorktreeOwners(sessionId, worktree.worktreePath), then remove sessionId's ownership entry. integrateWorktree also checks all co-owning sessions before merging so it cannot run while any co-owner has an active task.
    • Added regression in cli/src/agent/DiracAgent.worktree.test.ts verifying that deleting the source session retains the shared worktree and uncommitted files for the fork until the fork itself is deleted.
  • Synchronized fork snapshot capture (cli/src/agent/DiracAgent.ts, cli/src/agent/sessionHistory.ts):
    • Added runSynchronizedSessionOperation so unstable_forkSession, deleteSessionResources, and runSessionRuntimeMutation (including prompt() startup) serialize on the same per-session barrier.
    • captureForkSnapshot checks status === AcpSessionStatus.Processing inside runSynchronizedSessionOperation, and cloneForkedSessionArtifacts holds withTaskHistoryInventoryLock across the task-directory fs.cp, taskHistory upsert/flush, and copySessionUpdates (with deleteSessionResources acquiring the same lock).
    • Added 3 controlled interleaving regressions in cli/src/agent/DiracAgent.continuity.test.ts covering: (1) prompt initializing before fork enters synchronization, (2) prompt starting while fs.cp is in flight, and (3) source session deletion while fs.cp is in flight.
  • ACP SDK wire dispatch (cli/src/acp/AcpAgent.ts, cli/src/agent/DiracAgent.ts): Added listSessions and resumeSession aliases alongside unstable_listSessions and unstable_resumeSession so @agentclientprotocol/sdk's legacyAgentApp dispatches session/list and session/resume over stdio.

@dirac-run
dirac-run merged commit 6243813 into dirac-run:master Oct 24, 2026
1 check passed
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.

2 participants