feat: typed eval output + assembly-reload/cancel handling#2
Merged
Conversation
Eval and subscription results serialized the value to JSON and then sent it as a JSON-encoded string, so every consumer had to parse it a second time and the SDK's typed eval<T>/watch<T> actually returned a string rather than T. Emit the value as native JSON instead, carry the .NET type name in valueType, and signal oversized results with truncated/truncatedBytes (value null) rather than partial, invalid JSON. The SDK now returns the typed value directly and exposes the truncation fields, and the fake runtime mirrors the truncation contract so tests exercise it. BREAKING CHANGE: eval_result/subscribe_result value is native JSON instead of a JSON-encoded string; consumers that double-parsed value must stop.
The SDK silently dropped assembly_reload pushes and never sent the cancel frame, so hot reloads left stale command schemas cached and there was no way to stop an eval or an unwanted subscription. Surface reloads via Session.onAssemblyReload (invalidating the cached catalog and descriptors), add Session.cancel(targetId), and have watch() cancel its server subscription automatically when the iterator stops before final. Wire the server side so a cancel targeting a subscription id actually removes the subscription during the tick, not just queued/running evals. FakeRuntime gains matching helpers so the behavior is covered by tests.
a61e192 to
c498604
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two SDK/protocol improvements, each with its own changeset.
Native typed eval/subscription output (protocol + sdk, major)
Eval and subscription results previously emitted
valueas a JSON-encodedstring, forcing every consumer to parse the payload a second time (confirmed
on the live wire:
1+1returned"2",productNamereturned"\"Ardenfall Demo 2025\""). Results now carry:valueas native JSON,valueTypewith the .NET type name,truncated/truncatedBytespair that signals when a result exceedsmaxResultLength(in which casevalueisnullrather than partial,invalid JSON).
Session.eval<T>()/Session.watch<T>()return the typed value directly.Breaking for anyone who double-parsed
value, hence the major bump. Wiredthrough
JsonResultSerializer.ToWireValue,ReplEngine,SubscriptionManager, protocol records/schemas, the SDK, andFakeRuntime.Assembly-reload + cancellation (sdk + testing, minor)
Session.onAssemblyReloadsurfaces hot-reload pushes that were previouslydropped and invalidates the cached command catalog/descriptors so stale
schemas are never reused.
Session.cancel(targetId)cancels an active eval or subscription.watch()auto-cancels its server subscription when the iterator stopsbefore
final.ReplEngineTick.FakeRuntimegains matching helpers (onAssemblyReload/emitAssemblyReload,cancel/cancelled).Optional transport methods only — non-breaking for the transport contract.
Release
After merge, the changesets bump
@hotrepl/protocoland@hotrepl/sdkto4.0.0 (
@hotrepl/cli/@hotrepl/mcpget dependency-range patch bumps). Thechangesets Release workflow opens the Version PR; merging it publishes via
npm OIDC trusted publishing.