Skip to content

server: remove the Reconciler interface #514

Closed

Description

@rakyll

internal/server defines a Reconciler interface that Server uses to drive
task lifecycles on Agent Substrate:

// Reconciler coordinates sandbox/actor lifecycles on Agent Substrate directly.
type Reconciler interface {
	Reconcile(ctx context.Context, task *v1alpha1.Task, ws *v1alpha1.Workspace) (*v1alpha1.Task, error)
	ReconcileDelete(ctx context.Context, atespace, taskName string) error
}

The interface doesn't buy us anything, and is poorly designed.

Proposal

  • Delete server.Reconciler and Options.Reconciler.
  • Make Server depend on *controller.TaskReconciler directly. Another option
    is to build it inside NewServer from a *substrate.Client. It should also
    act as the tasks.Observer, so that one value is wired up in one place.
  • Remove the s.reconciler != nil branches in server.go.
  • Make a failure to create the Substrate client in cmd/ax-server fatal,
    instead of logging it and continuing without reconciliation.
  • Change server_test.go to use a real TaskReconciler against the fake
    Substrate gRPC servers that internal/controller tests already use, instead
    of fakeReconciler.

Affected code

  • internal/server/server.go: interface, Options, Server, and the call
    sites at the Reconcile / ReconcileDelete calls
  • cmd/ax-server/main.go: wiring
  • internal/server/server_test.go: fakeReconciler,
    TestServer_DirectReconcilerLifecycle

Activity

  1. self-assigned this
    on Oct 25, 2026
  2. yongruilin commented on Oct 28, 2026

    @yongruilin
    Collaborator

    @rakyll this seems straight forward. Can I take on this while I'm ramping up the project?

  3. assigned and unassigned on Oct 28, 2026
  4. added a commit that references this issue on Oct 28, 2026
    8a88ad5
  5. janetkuo commented on Oct 28, 2026

    @janetkuo
    Member

    @yongruilin @rakyll since we're removing this interface, there's a related clean-up worth doing here.

    Today, handlers tell the reconciler what action to take by mutating task.Status.Phase in memory before calling Reconcile. The reconciler then checks that value to decide whether to suspend or resume the actor. As noted in #515, this mixes intent with observed state.

    Since Server will call TaskReconciler directly, can we make the action explicit? For example, exposing separate Resume and Suspend methods on TaskReconciler rather than passing everything through a single Reconcile call. That also makes the "new tasks start suspended" behavior an explicit step in CreateTask rather than an implicit side effect of the phase field.

  6. yongruilin commented on Oct 28, 2026

    @yongruilin
    Collaborator

    @janetkuo Yea, I think it would be better. So basically we can replace reconciler.Reconcile() with explicit functions such as

    func (r *TaskReconciler) Suspend(ctx context.Context, task *v1alpha1.Task, ws *v1alpha1.Workspace) error
    func (r *TaskReconciler) Resume(ctx context.Context, task *v1alpha1.Task, ws *v1alpha1.Workspace) error
    func (r *TaskReconciler) Delete(ctx context.Context, atespace, name string) error

    and use them inside "Server" right?
    It prefer to have a follow-up PR stacked on #532 , feel free to put up one or I can try to do it? wdyt?

  7. added a commit that references this issue on Oct 29, 2026
    37dda66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions