Skip to content

Convert Nexus completion tokens across HSM and CHASM#11035

Draft
tekkaya wants to merge 1 commit into
gokhan/nexus-completion-run-fallbackfrom
gokhan/nexus-completion-token-conversion
Draft

Convert Nexus completion tokens across HSM and CHASM#11035
tekkaya wants to merge 1 commit into
gokhan/nexus-completion-run-fallbackfrom
gokhan/nexus-completion-token-conversion

Conversation

@tekkaya

@tekkaya tekkaya commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What changed?

On a NotFound from the framework a Nexus completion token targets, the frontend completion dispatcher now converts the token to the other framework (HSM ↔ CHASM) and retries once. This handles the rebuild escape hatch: a reset/conflict-resolution can re-create an operation under the other framework by dynamic config after its callback token was minted, leaving the token addressing the framework the operation no longer lives in.

Conversion routes through the nexusworkflowref package added in #11050 (HSMRefToCHASMRef / CHASMRefToHSMRef). The scheduled event ID is the join key; versioned transitions are not carried across — identity is re-established by request ID, matching the completion handlers' reset fallback. The HSM→CHASM direction is gated on the namespace having CHASM enabled (a CHASM-disabled namespace has no CHASM tree); CHASM→HSM is always attempted since HSM is the legacy default and returns a clean NotFound when absent.

Why?

Mirrors the reset reapply's cross-tree routing (#10986) at the live-completion layer — that PR's TODO explicitly flagged that "the completion-token resolution path (HSM StateMachineRef vs CHASM ComponentRef) also needs the same fallback." Without it, an async completion for an operation whose framework was flipped by a rebuild never lands.

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)

Functional: TestNexusOperationAsyncCompletionAfterFrameworkFlip completes an operation after a rebuild flips its framework in both directions, validated end-to-end in an integration branch with the reset stack applied.

Potential risks

Stacked on #11028 (run fallback), which is based on main. The nexusworkflowref package (#11050) and the reset stack (#10986, #10983) that produces the framework flip have merged, so #11028 is the only remaining dependency — the CHASM completion handler needs its ComponentCreation/CurrentRun fallback to resolve the converted (versioned-transition-less) token. With #11028 in the stack the functional test passes end-to-end (both flip directions). Kept as a draft until #11028 merges; GitHub retargets this PR to main at that point.

@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from fa93a90 to 14ec28b Compare July 14, 2026 06:04
@tekkaya
tekkaya changed the base branch from gokhan/nexus-completion-run-fallback to gokhan/nexus-operation-identity July 14, 2026 06:04
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from e7e6ff4 to 498c4d4 Compare July 14, 2026 08:35
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from 14ec28b to d989a8f Compare July 14, 2026 08:35
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from 498c4d4 to 06fe036 Compare July 14, 2026 08:59
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from d989a8f to 117fcc4 Compare July 14, 2026 09:00
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from 06fe036 to 0a0aeed Compare July 14, 2026 10:08
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch 2 times, most recently from c379b04 to f2c682e Compare July 14, 2026 11:37
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch 2 times, most recently from d37e756 to ddd4a7d Compare July 16, 2026 09:08
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from f2c682e to c053720 Compare July 16, 2026 09:16
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from ddd4a7d to 0d324bd Compare July 16, 2026 09:28
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch 2 times, most recently from b6c8681 to c7f1809 Compare July 16, 2026 15:00
@tekkaya
tekkaya force-pushed the gokhan/nexus-operation-identity branch from 0d324bd to a8b917e Compare July 16, 2026 19:19
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from c7f1809 to 7cc6148 Compare July 16, 2026 19:19
tekkaya added a commit 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 (#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 #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.
Base automatically changed from gokhan/nexus-operation-identity to main July 17, 2026 07:08
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch 2 times, most recently from d901982 to 59e28af Compare July 17, 2026 08:45
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.
A rebuild (reset or conflict resolution) can re-create a Nexus operation
under the other framework (HSM<->CHASM) by dynamic config after its
callback token was minted, leaving the token addressing the framework the
operation no longer lives in, so the completion is lost.

The frontend completion dispatcher now, on a NotFound from the token's
framework, converts the token to the other framework and retries once. The
conversion routes through framework-owned identity helpers via the shared
nexus.OperationIdentity, so the frontend does not parse either framework's
ref layout. Identity is re-established by request ID, matching the
completion handlers' reset fallback.

The HSM->CHASM direction is gated on the namespace having CHASM enabled (a
CHASM-disabled namespace has no CHASM tree, so the conversion would be
futile); CHASM->HSM is always safe since HSM is the legacy default.

Adds a dispatcher-fallback unit test and a functional test that completes
an operation after a rebuild flips its framework in both directions.
@tekkaya
tekkaya force-pushed the gokhan/nexus-completion-token-conversion branch from 59e28af to 6125185 Compare July 19, 2026 11:18
@tekkaya
tekkaya changed the base branch from main to gokhan/nexus-completion-run-fallback July 19, 2026 11:18
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