Skip to content

CHASM return same timestamp from context.Now() within same MutableCtx#10506

Open
awln-temporal wants to merge 3 commits into
mainfrom
awln/chasm-mutable-context-now-cache
Open

CHASM return same timestamp from context.Now() within same MutableCtx#10506
awln-temporal wants to merge 3 commits into
mainfrom
awln/chasm-mutable-context-now-cache

Conversation

@awln-temporal

@awln-temporal awln-temporal commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What changed?

Return same timestamp from context.Now() within same MutableCtx

Why?

Within each task execution, we are adding semantics that access from Now() in MutableCtx returns the same timestamp.

Rather than storing each timestamp locally within task execution, it's more convenient to return the same timestamp for each Now() call.

There are no guarantees across multiple tasks in the same transaction since it's not guaranteed a pure physical task execution will result in multiple logical tasks being ran, so we should treat tasks as isolated units.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@awln-temporal awln-temporal requested a review from a team as a code owner June 3, 2026 18:24

@rodrigozhou rodrigozhou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add more details to the PR summary? What's the motivation for this change? What problem is it solving?

Comment thread chasm/context.go Outdated
Comment thread chasm/context.go Outdated
@awln-temporal awln-temporal requested a review from rodrigozhou June 8, 2026 16:57
@awln-temporal awln-temporal force-pushed the awln/chasm-mutable-context-now-cache branch from 51d7d32 to d75dd38 Compare June 8, 2026 21:40
Comment thread chasm/context.go
type mutableCtx struct {
*immutableCtx

now **time.Time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why double pointer here?

@awln-temporal awln-temporal Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hm ok we can either do a combination of pointer struct of boolean + time.Time, or use double pointer. The problem is that you can create another delegate Ctx object with WithValue, and then if you call Now() the timestamp should get updated for all context objects with the same root Ctx.

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.

2 participants