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

+13 -3
View File
@@ -408,13 +408,20 @@ func daemonWithNATS(t *testing.T) (*Daemon, *store.Store, *arnats.Client) {
"parked": "archie:parked", "queued": "archie:queued", "dead": "archie:dead",
}},
}),
Store: s,
Tasks: client,
Log: slog.New(slog.DiscardHandler),
Store: s,
Tasks: client,
WorktreeGrants: fixedGrantIssuer{token: "test-worktree-grant"},
Log: slog.New(slog.DiscardHandler),
}
return d, s, client
}
type fixedGrantIssuer struct{ token string }
func (g fixedGrantIssuer) Issue(*store.Task) (string, func(), error) {
return g.token, func() {}, nil
}
func TestRequestTaskRunDoesNotSleepPastReadyDeadline(t *testing.T) {
d, _, _ := daemonWithNATS(t)
d.TaskRunReadyTimeout = 10 * time.Millisecond
@@ -620,6 +627,9 @@ func TestRunViaAgentSendsExpectedRequest(t *testing.T) {
if req.Cfg.DiffCapLines != 999 {
t.Fatalf("request Cfg.DiffCapLines = %d, want 999", req.Cfg.DiffCapLines)
}
if req.WorktreeGrant != "test-worktree-grant" {
t.Fatalf("request WorktreeGrant = %q, want dispatch grant", req.WorktreeGrant)
}
case <-time.After(time.Second):
t.Fatal("archied did not publish a taskrun request")
}