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
type mutableCtx struct {
*immutableCtx

nowByComponent map[*Node]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.

Can we call something else than "now" given that it's not really "now" after the first call?

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, what do you think this should be called? The method to access it is Now(), do you think if the map name was like cachedNowTimeByComponent that would be better?

@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?

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