Skip to content

Add metadata context support to mutable state#8966

Closed
nikki-dag wants to merge 1 commit intotemporalio:mainfrom
nikki-dag:nikki/mutable-state-context-map
Closed

Add metadata context support to mutable state#8966
nikki-dag wants to merge 1 commit intotemporalio:mainfrom
nikki-dag:nikki/mutable-state-context-map

Conversation

@nikki-dag
Copy link
Copy Markdown
Contributor

@nikki-dag nikki-dag commented Jan 8, 2026

What changed?

Adds metadata context support to history service gRPC calls while setting information before finalizing any mutable state transaction.

Why?

We want to pass mutable state metadata, such as workflow type, activity type, workflow task queue, and activity task queue, throughout the gRPC call lifecycle.

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)

Note

Introduces a per-request metadata context and populates it with workflow info during state transitions.

  • New contextutil metadata store with thread-safe, in-place ContextMetadataSet/Get
  • New gRPC MetadataContextInterceptor that injects metadata context into all history requests; wired via fx in fx.go
  • MutableStateImpl now sets workflow-type and workflow-task-queue into the request context at closeTransaction
  • Tests updated to stub event retrieval where needed

Written by Cursor Bugbot for commit 2cc1fbc. This will update automatically on new commits. Configure here.

@nikki-dag nikki-dag requested review from a team as code owners January 8, 2026 01:26
@nikki-dag nikki-dag force-pushed the nikki/mutable-state-context-map branch from 326c7cc to 0a83835 Compare January 8, 2026 01:27
Comment thread service/history/workflow/mutable_state_impl.go Outdated
@nikki-dag nikki-dag force-pushed the nikki/mutable-state-context-map branch from 0a83835 to efe6950 Compare January 8, 2026 01:59
Comment thread service/history/workflow/mutable_state_impl.go Outdated
Comment thread service/history/fx.go
metadataContextInterceptor *interceptor.MetadataContextInterceptor,
) []grpc.UnaryServerInterceptor {
return []grpc.UnaryServerInterceptor{
metadataContextInterceptor.Intercept,
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.

We don't need to inject this in OSS yet, let me know if you think I should remove it.

metadataContextKey struct{}

// metadataContext is used to store workflow and activity metadata that can be modified in-place
metadataContext struct {
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.

I can specify a more descriptive name for this map, such as "archetypeAttributesContext." Let me know if you have other suggestions or prefer to keep it generic.

@nikki-dag nikki-dag force-pushed the nikki/mutable-state-context-map branch from efe6950 to 07a6cde Compare January 8, 2026 02:19
@nikki-dag nikki-dag force-pushed the nikki/mutable-state-context-map branch from 07a6cde to 2cc1fbc Compare January 8, 2026 02:28
@nikki-dag nikki-dag closed this Jan 8, 2026
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.

1 participant