Skip to content

Add concurrent payload visitor#2140

Open
cconstable wants to merge 6 commits into
mainfrom
payload-traversal
Open

Add concurrent payload visitor#2140
cconstable wants to merge 6 commits into
mainfrom
payload-traversal

Conversation

@cconstable

@cconstable cconstable commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What was changed

  • Added a generic payload visitor for the TS SDK that walks over the WorkflowActivation / WorkflowActivationCompletion proto trees.
  • Added a proto/scripts/gen-payload-visitor.ts script that generates the visitors at proto/src/payload-visitor.generated.ts. Runs automatically when new protos are generated. About ~1k lines of checked in code.
await visitWorkflowActivation(activation, (payloads) => retrieve(payloads), { concurrency: 4 });

Why?

Prerequisite for External Storage store/retrieve (and reusable by codecs / payload validation): we need to find and transform every payload in an arbitrary proto message with bounded concurrency.

Comment on lines +54 to +60
- name: Check generated payload visitor is up to date
run: |
pnpm run gen:payload-visitor
if ! git diff --exit-code -- packages/proto/src/payload-visitor.generated.ts; then
echo "::error::payload-visitor.generated.ts is out of date with the protos. Run 'pnpm run gen:payload-visitor' and commit the result."
exit 1
fi

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.

safeguard to make sure generated protos stay up to data

@cconstable cconstable marked this pull request as ready for review June 23, 2026 23:54
@cconstable cconstable requested a review from a team as a code owner June 23, 2026 23:54
Comment thread package.json
"rebuild": "pnpm run clean && pnpm run build",
"build": "pnpm --recursive --stream run build",
"build:watch": "pnpm run build:protos && tsc --build --watch packages/*/tsconfig.json",
"build:watch": "pnpm run build:protos && pnpm run gen:payload-visitor && tsc --build --watch packages/*/tsconfig.json",

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.

Building the protos package now builds the payload visitor as well. I can't think of a reason why you wouldn't want to keep them in sync but you can still run build:protos to just build the protos.

* A counting semaphore. `acquire` resolves once a permit is available; `release` returns one,
* handing it directly to the longest-waiting acquirer if any.
*/
class Semaphore {

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.

Hand rolling concurrency primitives feels bad but I didn't see any reusable alternatives. I could move this to a different place if folks have opinions.

@jmaeagle99 jmaeagle99 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.

Haven't read too closely, but I think a few things need to be changed:

  • The visitor shouldn't enforce cardinality. If a callback wants to mutate the arity of an array, it should be able to e.g. codecs.
  • There needs to be some kind of context that is passed through while walking and a separate visitor that allows updating/replacing the context on a per-message basis. This would allow things like SerializationContext or StorageDriverStoreContext to change as we iterate commands in a WFT completion.
  • There should be settings for skipping search attributes and headers.

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.

4 participants