Skip to content

api, controller, server: add ForkTask RPC to branch from a parked task's snapshot - #669

Open
aprajitaarora13 wants to merge 1 commit into
mainfrom
aprajitaarora/fork-task-api
Open

aprajitaarora13 wants to merge 1 commit into
mainfrom
aprajitaarora/fork-task-api

Conversation

@aprajitaarora13

Copy link
Copy Markdown
Collaborator

Part 1 of #649 (followed by CLI, E2E, and hero-demo wiring in the stacked PR).

Adds the ForkTask gRPC method so callers can start a follow-up turn branched from a parked (SUSPENDED, IDLE, COMPLETED, or FAILED) task's durable workspace snapshot without mutating or reopening a terminal task:

  • API (pkg/apis/v1alpha1/):
    • Adds rpc ForkTask(ForkTaskRequest) returns (Task) to service AX, with ForkTaskRequest (atespace, source_task, name, labels, overrides) and ForkOverrides (commands, env, goal, config, session_id).
    • Adds parent_task and parent_tag on TaskStatus to record lineage and track the snapshot tag owned by the fork.
  • Controller (internal/controller/reconciler.go):
    • Adds ForkTagName, CreateForkTag (calls SuspendActorAndWaitForSnapshot before CreateTag so asynchronously parked actors have a completed durable snapshot), and DeleteForkTag.
    • Reuses the parent's recorded ActorTemplate and seeds the forked actor from status.parent_tag via EnsureActorFromTag, marking WorkspaceReady=True.
    • Cleans up status.parent_tag on DeleteTask after the forked actor is deleted.
  • Server (internal/server/fork.go):
    • Validates the request, locks the source task while snapshotting, inherits profile, workspace, gateway, debug, env, and session_id (unless overridden), merges env and labels overrides, creates the forked task suspended, and cleans up the tag on target creation race.
  • Tests: Adds controller and server unit tests (internal/controller/fork_test.go, internal/server/fork_test.go) and updates pkg/apis/v1alpha1/types_test.go.

Verified:

  • make verify (buf format, buf lint, buf generate, go mod tidy, go fmt, golangci-lint: 0 issues).
  • go test ./... passes.

…k's snapshot

# Conflicts:
#	internal/controller/reconciler.go
@mayawang

Copy link
Copy Markdown
Collaborator

Thanks Aprajita, this came together super cleanly! Forking from a parked task's snapshot fits keeping Task single-goal.

Let's hold #669 and #670 out of v0.4.0-rc.1 and keep Step 3 Turn 2 stubbed for now. Since this adds a new RPC and TaskStatus fields, two things to settle before we land it:

  • TaskStatus.parent_tag exposes the Substrate snapshot tag in the public API rather than keeping that mapping internal.
  • A fork inherits the parent's gateway and credentials with no way to narrow them.

Let's compare this with the same-Task approach on #649 and decide there.

@rakyll

rakyll commented Nov 23, 2026

Copy link
Copy Markdown
Member

Let's come back to this in v0.5.0.

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.

3 participants