fix(worktree): bind publication to dispatch grants

Worktree RPC used to accept repository coordinates from the sandbox. It now accepts only an opaque per-dispatch grant, and the daemon derives the repository path and branch from grant-owned state.

Repository worktree paths also move from an ambiguous flattened key to encoded owner/repo components. Origin-matched legacy clones migrate safely; mismatched legacy paths are preserved.
This commit is contained in:
sam committed 2026-08-22 22:06:54 +10:00
1 parent 7df2ae3626
commit dbb6550ab3
19 files changed
+494 -175

No files matched your search

+7
View File
@@ -29,6 +29,10 @@ type Request struct {
// transports, discover tools, and register them locally. Absent/empty
// means no MCP servers (backward compatible).
MCPServers []config.MCPServer `json:"mcp_servers,omitempty"`
// WorktreeGrant is an opaque, per-dispatch capability authorizing the
// daemon to publish this task's already-prepared branch. Repository
// coordinates never cross back from the sandbox as authority.
WorktreeGrant string `json:"worktree_grant,omitempty"`
}
// Validate rejects a full-task request that cannot be correlated to a real
@@ -40,6 +44,9 @@ func (r Request) Validate() error {
if r.Task.ID <= 0 {
return fmt.Errorf("task ID must be positive, got %d", r.Task.ID)
}
if r.WorktreeGrant == "" {
return errors.New("worktree grant is required")
}
return nil
}