openclaw - ✅(Solved) Fix bug: task startedAt timestamp is earlier than createdAt [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60632Fetched 2026-04-08 02:48:58
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1referenced ×1

In version 2026.4.2, task metadata records show startedAt < createdAt, which is logically impossible — a task cannot start before it was created.

Error Message

Task records contain timestamps where startedAt precedes createdAt. Audit tooling flags these as inconsistent_timestamps warnings. We observed 90 such warnings across our task history.

Root Cause

In version 2026.4.2, task metadata records show startedAt < createdAt, which is logically impossible — a task cannot start before it was created.

Fix Action

Fixed

PR fix notes

PR #60718: fix: resolve startedAt timestamp inversion in task registry

Description (problem / solution / changelog)

Summary

  • Problem: Task metadata records show startedAt < createdAt because callers assign startedAt = Date.now() prematurely before the registry inserts the record.
  • Why it matters: This logic invalidates chronological order, breaking observability/audit tools that expect strict startedAt >= createdAt invariants.
  • What changed: Moved startedAt default generation directly into task-registry.ts at the exact point of execution insertion. Clamped explicitly passed startedAt values (like from cron) safely via Math.max(createdAt, startedAt).
  • What did NOT change: createdAt assignment logic remained completely immutable.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #60632
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: Race conditions springing from execution handlers manually injecting Date.now() into startedAt fractions of a millisecond prior to the database/registry generating createdAt.
  • Missing detection / guardrail: No system-level validation checked if startedAt >= createdAt before assignment.
  • Contributing context (if known): Cron jobs must calculate their theoretical timing prior to their insertion tick.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/cron/service/cron-timestamp.test.ts
  • Scenario the test should lock in: Mocking Date.now() moving forward between payload generation and registry insertion, ensuring bounds are clamped correctly.
  • Why this is the smallest reliable guardrail: Simulates exactly the timeline delay identified in local auditing.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

None.

Diagram (if applicable)

Before:
[Runner eval: T] -> [Registry Insert: T+2] -> [Result: startedAt=T, createdAt=T+2 (Invalid)]

After:
[Runner eval: T] -> [Registry Insert: T+2] -> [Result: startedAt=T+2, createdAt=T+2 (Valid)]

## Changed files

- `src/acp/control-plane/manager.core.ts` (modified, +2/-3)
- `src/agents/acp-spawn.ts` (modified, +0/-2)
- `src/agents/subagent-registry-run-manager.ts` (modified, +0/-1)
- `src/tasks/cron-timestamp.test.ts` (added, +67/-0)
- `src/tasks/task-registry.ts` (modified, +24/-6)
RAW_BUFFERClick to expand / collapse

Description

In version 2026.4.2, task metadata records show startedAt < createdAt, which is logically impossible — a task cannot start before it was created.

Version

2026.4.2

Observed behavior

Task records contain timestamps where startedAt precedes createdAt. Audit tooling flags these as inconsistent_timestamps warnings. We observed 90 such warnings across our task history.

Expected behavior

startedAt should always be ≥ createdAt.

Steps to reproduce

  1. Schedule and run a cron task.
  2. After execution completes, inspect the task metadata (e.g. via the sessions/task log).
  3. Compare createdAt vs startedAt fields — startedAt will be earlier than createdAt.

Impact

  • Audit and observability tools that validate timestamp ordering report false inconsistencies.
  • Any downstream logic that relies on startedAt >= createdAt invariant will break silently.

extent analysis

TL;DR

Update the task metadata generation logic to ensure startedAt is always greater than or equal to createdAt.

Guidance

  • Review the cron task execution code to identify where startedAt and createdAt are being set, and verify that startedAt is not being populated before the task is fully created.
  • Inspect the database or storage mechanism used for task metadata to check for any potential timestamp inconsistencies or clock skew issues.
  • Consider adding a validation check when updating task metadata to ensure startedAt is not earlier than createdAt, and correct any inconsistencies found.
  • Test the fix by scheduling and running a cron task, then verifying that the startedAt and createdAt fields in the task metadata are correctly ordered.

Example

No code snippet is provided due to lack of specific implementation details in the issue.

Notes

The root cause of the issue is likely due to a logic error in the task metadata generation code, but without more information about the implementation, it's difficult to provide a more specific fix.

Recommendation

Apply a workaround by adding a validation check to ensure startedAt is not earlier than createdAt when updating task metadata, as the exact cause of the issue is not clear from the provided information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

startedAt should always be ≥ createdAt.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING