Repository navigation
Runner proto lifecycle - #633
Merged
Merged
Conversation
…n contracts Establish the minimal shared seam between the Task Reconciliation Loop and the Task Runner + ax-server workstreams: - Add transactional TaskApplier (TaskKey, TaskRow, DeleteTaskRow sentinel, ApplyFunc, LifecycleState / SetLifecycleState, ScrubStoredTask) and ErrLockTimeout in internal/store. - Add pure Task lifecycle contract types (ActionKind, SuspendReason, Action, State, sealed Input variants, Output, TransitionFunc, IsTerminal), Transition contract stub, and NextReconcileAt in internal/lifecycle. - Sync AGENTS.md and skills/substrate/SKILL.md.
- Clarify on CreateInput that CreateTask always initializes new tasks in TASK_STATE_QUEUED (starting directly in TASK_STATE_SUSPENDED is unsupported). - Guard nil receiver in (*TaskRow).SetLifecycleState and document Task.Status initialization in ApplyFunc. - Guard non-zero ClaimDeadline in NextReconcileAt so a zero time cannot schedule a QUEUED task as permanently overdue. - Expand lifecycle and store unit tests for past NotBefore, zero ClaimDeadline, terminal SUSPEND_ACTOR_SYNC, LastResumedAt, and nil-field/nil-receiver isolation. Signed-off-by: siyuanfoundation <[email protected]>
- Drop MaxQueueWaitDuration so RESOURCE_EXHAUSTED backs off RESUME_ACTOR while keeping the task in TASK_STATE_QUEUED rather than failing after 30m (#468). - Remove the ErrUnimplemented Transition stub (transition.go) so the state-machine PR adds Transition alongside its real implementation; preserve pure-transition contract invariants on TransitionFunc. Signed-off-by: siyuanfoundation <[email protected]>
- Drop queue, lease, sweep, and timer types (Action, ActionKind, SuspendReason, NextReconcileAt, ErrLockTimeout, reconciler/sweep inputs) so this phase reuses AX's synchronous Substrate lifecycle path (#515, #468, #592). - Extract server.storedStatus into store.StoredStatus and use it in TaskRow.SetLifecycleState so stored TaskStatus.state covers only AX-owned states while live actor state continues to be read from Substrate. - Track Runnable, ClaimNonce, RunnerToken*, ActiveRunID, RunSeq, and LastAckedRunnerSeq on lifecycle.State for pull-based runner assignment and event fencing. Signed-off-by: siyuanfoundation <[email protected]>
- Move runner control fields directly onto store.TaskRow and remove internal/lifecycle from this seam so the runner + ax-server PR introduces internal/lifecycle alongside its real Transition implementation and tests. Signed-off-by: siyuanfoundation <[email protected]>
mayawang
approved these changes
Nov 17, 2026
mayawang
left a comment
Collaborator
There was a problem hiding this comment.
LGTM to land the contract, with two things to settle before the :8081 handler wires it up:
- v0.1 risk: restartedSameRun also matches on in_memory_run_id, but if that's set the runner survived, so it wasn't a restart. An interactive task (or one suspended mid-setup) resumed from a memory snapshot would come back FAILED/SANDBOX_CRASHED, which hits the suspend/resume demo step. Crash should mean in_memory empty and last_started matching.
- Long-term: ExecSpec/GoalPayload duplicate what the mounted runner already reads from the Task (goal, config, MCP, launcher choice), and argv is empty for goal tasks with no defined meaning. Could we pick one source of truth? That would also give goal-less interactive tasks IDLE instead of RUN (#632).
Small: ApplyEvents could guard on IsTerminal so a late CommandExited can't overwrite CANCELLED.
Collaborator
Author
Collaborator
Author
Addressed in follow-up #635 |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on the common-ground TaskRow / TaskApplier seam (internal/store/task_apply.go, internal/server/server.go, AGENTS.md). Introduces the minimal pull-based runner wire contract (ax.runner.v1) and the pure, I/O-free task/runner state transitions operating directly on store.TaskRow, with zero server or runner runtime wiring yet.
Introduces the minimal pull-based runner wire contract (
ax.runner.v1) and the pure, I/O-free task/runner state transitions operating directly onstore.TaskRow(#591seam), with zero server or runner runtime wiring yet.Key Changes
pkg/apis/runner/v1/runner.proto(runner.pb.go): AddsAssignmentMode(IDLE,RUN,RESUME,SETUP),ClaimAssignmentRequest/Response,ExecSpec,GoalPayload, andReportEventsRequest/Response(SetupFinished,CommandStarted,CommandExited).internal/lifecycle/lifecycle.go:Claim: per-actorX-AX-Runner-Tokenminting withClaimNonceretry idempotency,RUNvsRESUME(liveMEMORYchild) vsSANDBOX_CRASHED(unexpected restart) vsIDLEselection.ApplyEvents:seqdeduplication,run_idfencing, and terminalCOMPLETED/FAILEDTaskOutcomerecording withparkActorsignaling onCommandExited.IsTerminal/IsExecutionTerminal: treatsPROVISIONING_FAILED(with noOutcome) as retryable while locking terminal execution outcomes.Testing
go test -v -count=1 ./internal/lifecycle/... ./pkg/apis/runner/...golangci-lint run ./internal/lifecycle/... ./pkg/apis/runner/...(0 issues)