Skip to content

The Ready condition's update time changes on every read, even when nothing changed #539

Open

Description

@mastersingh24

What happens

Every time you read a task, its Ready condition comes back with a new updateTime, even though the task and its actor haven't changed. So the timestamp no longer tells you when the task last changed, which is what clients use it for. Anything that polls ax and looks for changes, like a dashboard or a sync loop, sees every task as changed on every poll.

This started with #515, when Ready became derived from the actor's state on each read. The comment on setReady says the update time changes only when the condition does, but that's only true within a single call.

Example

A test against upstream main (f0228f1) creates a task, then calls GetTask twice, a second apart:

s1, t1 := ready() // GetTask, then return the phase, Ready status, reason and updateTime
time.Sleep(1100 * time.Millisecond)
s2, t2 := ready()
first GetTask:  Suspended False Suspended updateTime=2026-10-31T18:40:08.767301281Z
second GetTask: Suspended False Suspended updateTime=2026-10-31T18:40:09.868168323Z
--- FAIL: Ready did not change, but its updateTime did

The cause is in internal/server/server.go. storedStatus drops the Ready condition before saving, for any phase that comes from Substrate. On the next read there's no Ready condition to compare against, so setReady appends a new one with UpdateTime: timestamppb.Now().

We hit this in substrate-scope, a visualizer that polls ax. It had to start ignoring Ready's updateTime altogether to stop treating every task as changed on every poll.

Proposed solution

Give the derived Ready condition a timestamp that only moves when its inputs do. Substrate already has one: the actor's metadata.update_time, which changes on every mutation of the actor. When Ready is built from the actor's state, use that time (or the later of it and the WorkspaceReady condition's time, since a running task's Ready also depends on workspace setup) instead of timestamppb.Now(). Repeated reads of an unchanged task then return the same value, and a real change still moves it.

Another option is to store the last derived Ready condition and keep its time when the new one matches. That works too, but it puts a write on the read path, and the actor's own timestamp already answers the question.

Activity

  1. mastersingh24 commented on Oct 31, 2026

    @mastersingh24
    ContributorAuthor

    Fix is on https://github.com/mastersingh24/ax/tree/fix-ready-update-time (commit 06454ee). Ready now takes the actor's metadata.update_time, or WorkspaceReady's time for a running task when that is later. The SubstrateUnavailable and ActorNotFound cases have no actor timestamp and still use the current time. PR to follow.

  2. yjjnls commented on Nov 19, 2026

    @yjjnls

    Confirmed still present on current main (@ af62e9d) — the anchors have moved since this was filed, so here is the updated map:

    • StoredStatus (internal/store/task_apply.go:137-158, the runner seam from store: add TaskRow, TaskApplier, and StoredStatus runner seam #591) still drops the Ready condition for every state outside IsAXTaskState (pkg/apis/v1alpha1/types.go:136-145), so live-derived phases like WORKING/SUSPENDED never persist Ready.
    • On every read (getTask → applyActor → setActorStatus, internal/server/server.go:529/605/618) the condition is recomputed, and the stored status has no Ready to compare against, so setReady (:721-741) falls through to the append branch stamped timestamppb.Now(). A read writes nothing back, so every GetTask/ListTasks returns a fresh updateTime on an unchanged task — exactly the false change your substrate-scope poller had to filter out.

    @mastersingh24 you filed this and posted fix-ready-update-time @ 06454ee with "PR to follow" 19 days ago, and no PR has appeared since. Are you still planning to submit it? If the collaborators_only policy (#358) is what's blocking, a maintainer can open the PR from your fork (that's the route MushuEE offered on #489), and if the branch just needs attention, happy to help however is useful.

    Two observations from an independent walkthrough, offered as input for your fix rather than a competing patch — it's your issue and your approach, so I'm not attaching one:

    1. The stable-source idea still fits the seams that have landed since 10-31. The store/schema refactors (task: update v1alpha1 Task and ObjectMeta schema and update codebase #587, api: clean up v1alpha1 proto field numbers and Task status types #605, store: add TaskRow, TaskApplier, and StoredStatus runner seam #591) kept both touchpoints your branch needs: the actor object is at hand in setActorStatus (so actor.metadata.update_time is available), and WorkspaceReady is one of the conditions that survives storage — only Ready is stripped — so "the later of actor update time and WorkspaceReady time" composes cleanly with the running-task branch at server.go:666-671. Expect a rebase (your base is f0228f1), but no redesign.

    2. The residual-churn windows are the error and terminating branches. SubstrateUnavailable (:636), ActorNotFound (:647), and the terminating branches (:631/:640/:656) have no actor timestamp to source, so a task parked in any of those states keeps minting a fresh updateTime per read — the same false-change signal, just confined to error/deletion windows. Anything sourcing those stamps from data that survives the StoredStatus strip avoids it; sourcing from the actor can't work there by construction (there is no actor), which is presumably why the wall-clock fallback exists. Worth deciding explicitly whether documented churn in those states is acceptable, or whether the last value should be carried in a stored field.

    One guard worth adding either way: a test that pins the real control plane's metadata.update_time population on GetActor responses — your fake change mirrors it, but if Substrate ever stops setting it, every stamp degrades to zero-time/Now silently.

    Happy to test the branch against current main when it lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions