Add HSM<->CHASM Nexus completion conversion#11050
Conversation
06fe036 to
0a0aeed
Compare
0a0aeed to
d37e756
Compare
| // 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 |
There was a problem hiding this comment.
what does this mean? If a nil lastUpdateVT is specified at RefConsistencyLevelExecutionLastUpdate is that any different than RefConsistencyLevelComponentCreation?
There was a problem hiding this comment.
Good catch, they're effectively identical here, so the comment is misleading. I'll fix it
ddd4a7d to
0d324bd
Compare
bergundy
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
0d324bd to
a8b917e
Compare
Thought about putting it inside components but tt's a converter, not a component, so it felt wrong; and |
## 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.
What changed?
Adds a top-level
nexusworkflowrefpackage exposing two functions that convert a Nexus operation completion token between its HSM and CHASM forms:HSMRefToCHASMRef— HSMStateMachineReftoken → CHASMChasmComponentReftokenCHASMRefToHSMRef— the reverseBoth directions rebuild the target framework's ref from the fields shared by the two representations (namespace, workflow, run, scheduled event ID, request ID).
CHASMRefToHSMRefonly accepts workflow-backed operations: it verifies the ref'sWorkflowArchetypeIDand 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?
Potential risks
Low — additive, and only invoked by #11035. The one coupling to watch: the converter encodes the CHASM
Operationsmap field name andWorkflowArchetypeID; a change to the workflow component's layout must be reflected here.