Skip to content

Add HSM<->CHASM Nexus completion conversion#11050

Merged
tekkaya merged 1 commit into
mainfrom
gokhan/nexus-operation-identity
Jul 17, 2026
Merged

Add HSM<->CHASM Nexus completion conversion#11050
tekkaya merged 1 commit into
mainfrom
gokhan/nexus-operation-identity

Conversation

@tekkaya

@tekkaya tekkaya commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What changed?

Adds a top-level nexusworkflowref package exposing two functions that convert a Nexus operation completion token between its HSM and CHASM forms:

  • HSMRefToCHASMRef — HSM StateMachineRef token → CHASM ChasmComponentRef token
  • CHASMRefToHSMRef — the reverse

Both directions rebuild the target framework's ref from the fields shared by the two representations (namespace, workflow, run, scheduled event ID, request ID). CHASMRefToHSMRef only accepts workflow-backed operations: it verifies the ref's WorkflowArchetypeID and its ["Operations", "<scheduledEventID>"] component path before converting.

Why?

Preparation for the cross-framework Nexus completion fallback (#11035), where a completion whose token targets one framework must be retried against the other after a rebuild (reset or conflict resolution) flips the operation's framework.

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)

Potential risks

Low — additive, and only invoked by #11035. The one coupling to watch: the converter encodes the CHASM Operations map field name and WorkflowArchetypeID; a change to the workflow component's layout must be reflected here.

@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch 3 times, most recently from 06fe036 to 0a0aeed Compare July 14, 2026 10:08
@tekkaya
tekkaya changed the base branch from gokhan/nexus-completion-run-fallback to main July 14, 2026 10:08
@awln-temporal
awln-temporal self-requested a review July 15, 2026 17:23
@tekkaya
tekkaya marked this pull request as ready for review July 15, 2026 18:03
@tekkaya
tekkaya requested review from a team as code owners July 15, 2026 18:03
@tekkaya
tekkaya requested a review from bergundy July 15, 2026 18:04
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from 0a0aeed to d37e756 Compare July 15, 2026 18:06
// CompletionFromOperationIdentity builds a CHASM-format Nexus completion token addressing the operation identity.
// The ComponentRef carries no versioned transitions, so it MUST be resolved at
// chasm.RefConsistencyLevelComponentCreation or chasm.RefConsistencyLevelCurrentRun. It must NOT be resolved at
// the default chasm.RefConsistencyLevelExecutionLastUpdate: with a nil execution transition the staleness check is

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.

what does this mean? If a nil lastUpdateVT is specified at RefConsistencyLevelExecutionLastUpdate is that any different than RefConsistencyLevelComponentCreation?

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.

Good catch, they're effectively identical here, so the comment is misleading. I'll fix it

@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch 2 times, most recently from ddd4a7d to 0d324bd Compare July 16, 2026 09:28

@bergundy bergundy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Functionally, this LGTM. I would just like to organize the code a bit differently.
I would make a separate package nexusworkflowref or something that exposes only HSMRefToCHASMRef and CHASMRefToHSMRef. I think that should be enough and you can later invoke it either in the frontend or the history handler (I still haven't considered where the best place is).

// owns each representation provides the extract/build helpers (see components/nexusoperations for
// HSM and chasm/lib/workflow for CHASM), so callers can convert a token between frameworks without
// knowing either framework's ref layout.
type OperationIdentity struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like it should live somewhere that's workflow specific. We also need to also do this conversion in the CHASM case when the ref has a component path, indicating that it's for a workflow (or by checking the archetype ID on it).

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.

changed into an internal private type

Introduce a nexusworkflowref package exposing HSMRefToCHASMRef and CHASMRefToHSMRef, which convert a Nexus operation completion token between its HSM and CHASM forms. A rebuild (reset or conflict resolution) can move a workflow's operation across frameworks by dynamic config after its callback token was minted, so a completion may address the framework the operation no longer lives in; converting the token lets it be retried against the current framework.

Only workflow-backed operations are convertible: the CHASM direction verifies the ref's workflow archetype and Operations component path.
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from 0d324bd to a8b917e Compare July 16, 2026 19:19
@tekkaya tekkaya changed the title Add framework-owned Nexus operation identity helpers Add nexusworkflowref for HSM<->CHASM Nexus completion conversion Jul 16, 2026
@tekkaya tekkaya changed the title Add nexusworkflowref for HSM<->CHASM Nexus completion conversion Add HSM<->CHASM Nexus completion conversion Jul 16, 2026
@tekkaya

tekkaya commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Functionally, this LGTM. I would just like to organize the code a bit differently. I would make a separate package nexusworkflowref or something that exposes only HSMRefToCHASMRef and CHASMRefToHSMRef. I think that should be enough and you can later invoke it either in the frontend or the history handler (I still haven't considered where the best place is).

Thought about putting it inside components but tt's a converter, not a component, so it felt wrong; and common/nexus imports neither framework today, so putting it there would force a common → components/chasm upward dependency and invert the layering. Placed at the repo root so it can be invoked from the frontend (or later the history handler) — open to relocating.

@tekkaya
tekkaya merged commit 3aec474 into main Jul 17, 2026
52 of 53 checks passed
@tekkaya
tekkaya deleted the gokhan/nexus-operation-identity branch July 17, 2026 07:08
davidporter-id-au pushed a commit to davidporter-id-au/temporal that referenced this pull request Jul 17, 2026
## What changed?
Adds a top-level `nexusworkflowref` package exposing two functions that
convert a Nexus operation completion token between its HSM and CHASM
forms:
- `HSMRefToCHASMRef` — HSM `StateMachineRef` token → CHASM
`ChasmComponentRef` token
- `CHASMRefToHSMRef` — the reverse

Both directions rebuild the target framework's ref from the fields
shared by the two representations (namespace, workflow, run, scheduled
event ID, request ID). `CHASMRefToHSMRef` only accepts workflow-backed
operations: it verifies the ref's `WorkflowArchetypeID` and its
`["Operations", "<scheduledEventID>"]` component path before converting.

## Why?
Preparation for the cross-framework Nexus completion fallback (temporalio#11035),
where a completion whose token targets one framework must be retried
against the other after a rebuild (reset or conflict resolution) flips
the operation's framework.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
Low — additive, and only invoked by temporalio#11035. The one coupling to watch:
the converter encodes the CHASM `Operations` map field name and
`WorkflowArchetypeID`; a change to the workflow component's layout must
be reflected 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.

3 participants