Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User metadata on workflows/events for user interface usage #371

Merged
merged 9 commits into from
May 17, 2024

Conversation

cretz
Copy link
Member

@cretz cretz commented Mar 18, 2024

What changed?

  • Added temporal.api.sdk.v1.UserMetadata containing payloads for summary and details for general metadata use
  • Added temporal.api.command.v1.Command.user_metadata for general use (initially only for timers and child workflow)
  • Added temporal.api.history.v1.HistoryEvent.user_metadata for general use (initially only for timers)
  • Added temporal.api.workflowservice.v1.StartWorkflowExecutionRequest.user_metadata for general use (initially for populating execution config)
  • Added temporal.api.workflowservice.v1.SignalWithStartWorkflowExecutionRequest.user_metadata for same reason as start
  • Added temporal.api.workflow.v1.NewWorkflowExecutionInfo.user_metadata for same reason as start
  • Added temporal.api.workflow.v1.WorkflowExecutionConfig.user_metadata for general use (initially for fixed as-of-start summary/details)
  • Added temporal.api.sdk.v1.WorkflowMetadata.current_details for the ability to have queryable long-form text representing current details of a workflow
  • Removed temporal.api.sdk.v1.WorkflowDefinition.definition because a workflow definition's description isn't best placed on a query (but "current details" is good on the metadata itself)

Why?

  • Users need a way to set fixed summary/details when starting a workflow for use by UIs
  • Users need a way to have query-obtainable live "current details" for use by UIs
  • Users need a way to set a summary when starting a timer for use by UIs
  • All of this needs to be encrypted if the user wants
  • We need to take into account future user-metadata use

Breaking changes

  • Yes for workflow metadata which was only used in JSON form by one SDK (TypeScript) and not even invoked by UI yet

@cretz cretz requested review from a team as code owners March 18, 2024 19:46
Comment on lines 39 to 47
// Short-form text that provides a summary. This payload should be a "json/plain"-encoded payload
// that is a single JSON string. Formatting may not apply to this text when used in "title"
// situations. The payload data section is currently limited to 400 bytes.
temporal.api.common.v1.Payload summary = 1;

// Long-form text that provides details. This payload should be a "json/plain"-encoded payload
// that is a single JSON string. Formatting may apply to this text in common use. The payload data
// section is currently limited to 20000 bytes.
temporal.api.common.v1.Payload details = 2;
Copy link
Member Author

Choose a reason for hiding this comment

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

Notes:

  1. Considered "description" instead of "details", but description isn't a general-purpose-enough term
  2. The 400 and 20000 bytes is an arbitrary ceiling based on expected use, happy to change
  3. These are payloads so they can be encrypted
  4. The use of JSON string as the type is a simple compatibility thing
  5. At this time, we are not defining the long-form format (but I suspect some very limited form of markdown)

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is safe for reworking in an incompatible way because it's just models for a well-known workflow query. See description to understand the changes.

Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

All of the fields are just plain text at the moment, right?
Would be nice to understand what the format is.

temporal/api/command/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/sdk/v1/user_metadata.proto Outdated Show resolved Hide resolved
@@ -35,20 +35,19 @@ option csharp_namespace = "Temporalio.Api.Sdk.V1";
message WorkflowMetadata {
// Metadata provided at declaration or creation time.
WorkflowDefinition definition = 1;
// Current long-form details of the workflow's state. This is used by user interfaces to show
// long-form text. This text may be formatted by the user interface.
string current_details = 2;
Copy link
Member

Choose a reason for hiding this comment

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

This is always returned in query responses and goes through the user's DC, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right

// An optional workflow description provided by the application.
// By convention, external tools may interpret its first part,
// i.e., ending with a line break, as a summary of the description.
string description = 2;
Copy link
Member

Choose a reason for hiding this comment

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

It this okay to break? Do we have any consumers of this as protos?

Copy link
Member Author

@cretz cretz Mar 18, 2024

Choose a reason for hiding this comment

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

Yes it's ok to break, no we don't have any consumers of it except TypeScript SDK internally (and not this field and we only use this as JSON not proto). Explained in description and in comment.

temporal/api/sdk/v1/user_metadata.proto Outdated Show resolved Hide resolved
@cretz
Copy link
Member Author

cretz commented Mar 18, 2024

All of the fields are just plain text at the moment, right?

Yes, this is documented on the field

Would be nice to understand what the format is.

Mentioned here, I am intentionally leaving that as out-of-scope for now pending some UI discussions. We should not block this progress on that.

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Looking good to me, just minor stuff.

temporal/api/command/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/sdk/v1/user_metadata.proto Outdated Show resolved Hide resolved
temporal/api/workflow/v1/message.proto Outdated Show resolved Hide resolved
@@ -35,20 +35,19 @@ option csharp_namespace = "Temporalio.Api.Sdk.V1";
message WorkflowMetadata {
// Metadata provided at declaration or creation time.
WorkflowDefinition definition = 1;
// Current long-form details of the workflow's state. This is used by user interfaces to show
// long-form text. This text may be formatted by the user interface.
string current_details = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Why a Payload in history and a string here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this object is a query result and query results are payloads already (so already subject to encryption in transit) whereas in history if you want something encrypted at rest it needs to be a payload.

// Short-form text that provides a summary. This payload should be a "json/plain"-encoded payload
// that is a single JSON string. Formatting may not apply to this text when used in "title"
// situations. The payload data section is limited to 400 bytes by default.
temporal.api.common.v1.Payload summary = 1;
Copy link
Member

Choose a reason for hiding this comment

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

I assume we considered this as a map from string to Payload.. why not do that? (For the record I like this better, just wondering what the reasoning was.)

Copy link
Member Author

Choose a reason for hiding this comment

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

There were a few of reasons that was rejected (there's an internal document discussing this). The primary reasons were that 1) the stringly-typed contract was too loose, 2) the keys are not user-defined, and 3) it unnecessarily increased history size for fixed keys.

@cretz cretz changed the title [DO NOT MERGE] User metadata on workflows/events for user interface usage User metadata on workflows/events for user interface usage Mar 26, 2024
buf.yaml Outdated Show resolved Hide resolved
@cretz cretz requested a review from a team April 16, 2024 16:51
// are used by user interfaces to show fixed as-of-start workflow summary and details.
// * start_timer_command_attributes - populates temporal.api.history.v1.HistoryEvent for timer
// started where the summary is used to identify the timer.
temporal.api.sdk.v1.UserMetadata user_metadata = 301;
Copy link
Contributor

Choose a reason for hiding this comment

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

why choose the field number 301? Why not 18 (next immediate available number) or 100 (if we want to group in hundreds)?
Just curious about the convention we use when picking field numbers in proto.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same reason why the person who added HistoryEvent.worker_may_ignore as 300, so that it would not interfere with our continually added, incrementally numbered attribute fields below. I chose 301 instead of 300 just to match history event's equivalent, but don't have to. The field number doesn't really matter much here, so it leaves room for attributes to keep adding.

# Conflicts:
#	buf.yaml
#	openapi/openapiv3.yaml
@cretz cretz merged commit de9e005 into temporalio:master May 17, 2024
3 checks passed
@cretz cretz deleted the user-metadata branch May 17, 2024 19:53
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.

8 participants