Update thread_ts and parent_ts fields to represent checkpoint IDs (uuids) instead of timestamps

Summary

Following the LangGraph 0.1 to 0.2 migration, thread_ts and parent_ts fields no longer represent timestamps but rather checkpoint IDs (workflow UUIDs). This issue tracks the necessary changes to align our codebase with this new semantic meaning.

See #470469 (comment 2546292256) See blog

Background

In LangGraph 0.1, these fields were actual timestamps. However, as documented in the LangGraph migration guide, they were changed to represent checkpoint_id and parent_checkpoint_id respectively. Since we already store checkpoint and workflow UUIDs separately, we need to update our implementation to reflect this change.

Proposed Changes

1. GraphQL Type Updates

File: ee/app/graphql/types/ai/duo_workflows/workflow_event_type.rb

Change the field types from TimeType to String:

  • timestamp field: Types::TimeTypeGraphQL::Types::String
  • parent_timestamp field: Types::TimeTypeGraphQL::Types::String

2. Model Scope Update

Not needed because thread_ts/parent_ts are using uuid_v7 which is time ordered

This not needed - it turns out thread_ts is

File: ee/app/models/ai/duo_workflows/checkpoint.rb Update the ordering scope to use created_at instead of thread_ts:

  • ordered_with_writes scope: order(thread_ts: :desc)order(created_at: :desc)

3. Presenter Updates

File: ee/app/presenters/ai/duo_workflows/workflow_checkpoint_event_presenter.rb

Remove time parsing and return the IDs directly:

  • timestamp method: Remove Time.parse() wrapper, return event.thread_ts directly
  • parent_timestamp method: Remove Time.parse() wrapper, return event.parent_ts directly

4. Rake Task Updates

File: ee/lib/tasks/gitlab/duo_workflow/duo_workflow.rake

Update test data generation to use UUIDs instead of timestamps:

  • In create_checkpoint_data method:
    • Change thread_ts from Time.current.iso8601(6) to SecureRandom.uuid
    • Change parent_ts from time-based calculation to SecureRandom.uuid (when step > 0)

Implementation Notes

  • These fields will now contain UUID strings instead of timestamp strings
  • The change is semantic only - the database column types remain the same (likely string/text)
  • Ensure any frontend code consuming these fields is updated accordingly

Testing Checklist

  • Update factories and unit tests for the presenter methods
  • Update GraphQL query tests to expect string types
  • Verify rake task generates valid UUID data
  • Test checkpoint ordering still works correctly with created_at
  • Ensure no regressions in workflow event display
Edited by Alper Akgun