Skip to content

Add a Nexus serialization context sample - #540

Merged
litlep-nibbyt merged 11 commits into
mainfrom
codex/typescript-nexus-serialization-context
Nov 25, 2026
Merged

litlep-nibbyt merged 11 commits into
mainfrom
codex/typescript-nexus-serialization-context

Conversation

@litlep-nibbyt

Copy link
Copy Markdown
Contributor

Add a Nexus serialization context sample with synchronous and workflow-backed asynchronous operations through four endpoints.

Two handler workers each serve two endpoints with distinct AES-GCM keys. One compresses before encrypting; the other encrypts only. The caller uses a separate key for its workflow input and final result. Backing workflow inputs use the handler's key 1, while async results use the endpoint's key and compression.

The codec uses the SDK's per-call context argument and keeps shared configuration read-only. The README follows the Java walkthrough, and CI runs the sample tests with the pinned server build.

Validation: eight sample tests, root build/lint/format, and all 22 selected project test commands pass locally. The README walkthrough and Java interoperability in both directions pass.

Java counterpart: merged Java sample (PR #815).

@litlep-nibbyt
litlep-nibbyt marked this pull request as ready for review November 20, 2026 21:33
@litlep-nibbyt
litlep-nibbyt requested review from a team as code owners November 20, 2026 21:33
async: async.startOperation('echoAsync', message, { scheduleToCloseTimeout: '30s' }),
};
});
const started = await Promise.all(

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.

nit: this could be a single Promise.all of executeOperation calls. It would be simpler and avoids waiting each operations sync start before the async start.

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.

done!

private readonly workflowCodec: EndpointCodec;
private readonly endpoints: ReadonlyMap<string, EndpointCodec>;

constructor(role: 'caller' | 'compressed' | 'encrypted' = 'caller') {

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.

Could the NexusCodec constructor take (endpointCodecs: Map<string, PayloadCodec>, workflowCodec: PayloadCodec) instead of a role string, like the Python sample? That way users can add per-endpoint encryption and keep their existing codec for workflow payloads without changing NexusCodec.

@litlep-nibbyt litlep-nibbyt Nov 25, 2026 •

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.

Yes, it makes sense to have the sample show the happy path for reusing existing codecs.

litlep-nibbyt and others added 10 commits November 25, 2026 10:46
Test plaintext and encrypted payloads in the same batch. Add caller and
handler progress logging and document how to adapt the sample and its
example key reuse.
NexusCodec now takes a map of endpoint names to payload codecs and a
fallback codec for ordinary workflow payloads, and delegates to the
selected codec. This lets applications add per-endpoint encryption
while keeping their existing workflow codec. The sample's AES-GCM
implementation moves to EncryptionCodec, and its keys and role-based
setup move to codec-config.ts.

The caller workflow now awaits one Promise.all of executeOperation
calls instead of collecting operation handles and then their results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@litlep-nibbyt
litlep-nibbyt force-pushed the codex/typescript-nexus-serialization-context branch from a9a2170 to e6e31d3 Compare November 25, 2026 18:47
@litlep-nibbyt
litlep-nibbyt enabled auto-merge (squash) November 25, 2026 20:12
@litlep-nibbyt
litlep-nibbyt merged commit eabd7d4 into main Nov 25, 2026
13 checks passed
@litlep-nibbyt
litlep-nibbyt deleted the codex/typescript-nexus-serialization-context branch November 25, 2026 23:45
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