Skip to content

store, server: delete TaskApplier - #719

Merged
rakyll merged 2 commits into
mainfrom
remove-task-applier
Nov 23, 2026
Merged

rakyll merged 2 commits into
mainfrom
remove-task-applier

Conversation

@rakyll

@rakyll rakyll commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

AX is a simple CRUD system over Agent Substrate: Task/Actor provisioning and lifecycle are handled imperatively (under the per-task lock, returning Substrate failures directly to the client), while task execution is declarative. Because of that, we do not need a transactional TaskApplier state machine alongside store.Store.

This PR removes TaskApplier and has internal/server/server.go read and write tasks directly through store.Store under s.locker.Lock.

Summary

  • Store contract & backends:
    • Deleted TaskApplier, TaskVersion, TaskKey, ApplyFunc, DeleteTaskVersion, PrepareTaskVersionForApply, and OverlayTaskGeneration (internal/store/task_apply.go, internal/store/task_version_normalize.go, internal/store/task_apply_test.go, internal/store/memory/task_apply.go, internal/store/postgres/task_apply.go) and removed TestTaskApplier*.
    • Moved store.StoredStatus into internal/store/store.go with unit tests in internal/store/store_test.go.
    • Simplified MemoryStore.tasks back to map[string]*v1alpha1.Task and dropped the TASK_STATE_UNSPECIFIED -> TASK_STATE_QUEUED coercion in SaveTask (memory and postgres) so saving after clearing metadata.delete_time preserves TASK_STATE_UNSPECIFIED.
    • Removed the unused tasks.generation column migration from internal/store/postgres/schema.sql.
  • Server & wiring:
    • Deleted internal/server/task_applier.go, server.Options.TaskApplier, and its wiring in cmd/ax-server/main.go.
    • Updated CreateTask, DeleteTask, SuspendTask, ResumeTask, clearStoredTaskState, recordFailure, and deleteTask to write through saveTask, updateTask, getStoredTask, and s.store.DeleteTask.
    • Replaced failApplyTaskApplier with a store.Store wrapper in internal/server/server_test.go and added TestServer_ResumeAfterFailedDeleteClearsDeleteTime.
  • Docs & contract:
    • Updated AGENTS.md and DESIGN.md.

Verification

  • make verify (0 issues, no diff)
  • go build ./cmd/ax ./cmd/ax-server ./cmd/ax-runner
  • go test ./...
  • go test -race -count=1 ./internal/store/... ./internal/server/... ./cmd/ax-server/...
  • Tested with a local cluster
  • Postgres integration tests in internal/store/postgres run in CI.

Fixes #714

Task handlers in internal/server/server.go already serialize mutations per task under s.locker.Lock. Remove the redundant TaskApplier write path and have server.go persist task state directly through store.Store helpers.

- Remove TaskApplier, TaskVersion, TaskKey, ApplyFunc, DeleteTaskVersion, PrepareTaskVersionForApply, and OverlayTaskGeneration from internal/store, internal/store/memory, and internal/store/postgres.
- Move store.StoredStatus into internal/store/store.go (with unit tests in internal/store/store_test.go).
- Drop the TASK_STATE_UNSPECIFIED -> TASK_STATE_QUEUED coercion in SaveTask (memory and postgres) so saving after clearing metadata.delete_time preserves TASK_STATE_UNSPECIFIED.
- Remove the unused tasks.generation column migration from internal/store/postgres/schema.sql.
- Remove internal/server/task_applier.go, server.Options.TaskApplier, and its wiring in cmd/ax-server/main.go; update task handlers to use saveTask, updateTask, getStoredTask, and s.store.DeleteTask directly.
- Update AGENTS.md and DESIGN.md.

Fixes #714
@rakyll
rakyll requested a review from mayawang as a code owner November 23, 2026 04:54
@rakyll rakyll self-assigned this Nov 23, 2026
@rakyll
rakyll requested a review from yongruilin November 23, 2026 05:07

@yongruilin yongruilin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing really blocking, feel free to either fix it now or follow up before 1.0 .

Comment thread internal/server/server.go Resolved
Comment thread internal/server/server.go Resolved
Comment thread internal/store/store.go Resolved

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Dropping generation from schema.sql is safe on existing DBs too since the column has DEFAULT 1.

Heads-up that #665 and #669 both rely on TaskApplier, so they'll need a rebase once this lands.

- Drop TaskStatus.generation from the API; nothing reads it.
- Move StoredStatus into internal/server as the unexported storedStatus,
  next to saveTask and updateTask.
- Postgres SaveTask keeps saved_at when replacing a task, so setting or
  clearing delete_time no longer moves the task to the top of
  'ax get tasks'. Workspaces, gateways, and models are unchanged.
@rakyll
rakyll merged commit 5b04a09 into main Nov 23, 2026
13 checks passed
@rakyll
rakyll deleted the remove-task-applier branch November 23, 2026 19:04
JeffLuoo added a commit to JeffLuoo/ax that referenced this pull request Nov 24, 2026
Cost attribution and task timelines need a record of each change of task phase that joins with the actor events of Agent Substrate.

The first version of this change wrapped store.TaskApplier, which google#719 deleted. Now the task write helpers in internal/server emit the event. saveTask, updateTask, and deleteTask read the stored task before they write it. The caller holds the per-task lock, so that read gives the previous phase. After a successful write that changes the phase, the helper emits the event through the new telemetry.EmitAt, with the time at which the write finished.

The event carries ax.task.name, ate.atespace, ax.task.id, ax.task.phase, and ax.task.previous_phase. The store does not hold the actor UID, so the helper reads ate.actor.uid from Substrate when the phase becomes Provisioned. Main has no row generation and no TaskResult, so the event has no generation, outcome, or exit code. A failed write, or a write that keeps the phase, emits nothing.
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.

store, server: delete TaskApplier

3 participants