Repository navigation
feat(sdk)!: run the Node SDK lifecycle in the shared Rust protocol - #4963
Open
ScriptedAlchemy wants to merge 8 commits into
Open
ScriptedAlchemy wants to merge 8 commits into
ScriptedAlchemy wants to merge 8 commits into
Conversation
Move request preparation, envelope and problem admission, SSE framing, the delivered cursor, and the reconnect budget into `protocol`, which performs no I/O. The blocking client now only reads and writes bytes for it, so an async transport can reuse the same rules (#4226). Generate `OPERATION_CONTRACTS` from the canonical registry so callers can resolve an operation's lifecycle contract by identifier. Fix defects the TypeScript client already guarded against: - Evidence pages decode through the canonical `PageState`: opaque `{kind, cursor}` continuations are admitted, bare strings and non-canonical cursors are refused, and `returned` may not exceed `total`. - Problems must be bound to the invoked binding; denials name none. - Receipts must not end before they start, and cancelled or timed-out receipts must carry cancellation evidence. - Curation receipts must carry a scope whose digest commits to it. - Operations accept page size and cursor options. - 401/403 and non-JSON media are refused from the response head, before reading a body that would be discarded. The shared problem-detail fixture is proven against `ApplicationProblem::from_detail` so other clients can build canonical problems from it. Refs #4226 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`@tracedecay/sdk` becomes a generated TypeScript facade over a Node-API binding (`crates/tracedecay-sdk-node`) of the Rust SDK protocol. Node and Rust now admit the same envelopes, problems, stream frames, terminal states and reconnects, and the TypeScript lifecycle runtime (SSE parsing, envelope and problem validation, cursor and reconnect handling) is deleted. Boundary ownership: - Network waits run on the binding's Tokio runtime; the event loop is never blocked. - An AbortSignal interrupts the in-flight native request and closes its connection. It never cancels the daemon operation; `cancelOperation` does. - A stream reads its body only when the iterator asks for an event, so a slow consumer applies TCP backpressure. Early return, `close`, or abort release the connection. - Errors cross as one typed payload and map onto the unchanged public error classes. - MCP-backed operations stay on the caller's adapter and never load the binding. Packaging: Bazel builds the addon as a `rust_shared_library` emitted by the BUILD generator. `scripts/native-packages.mjs` stages napi-rs style `@tracedecay/sdk-<platform>` packages from `.github/release-targets.json` and links them as optionalDependencies at release time. Hosts can pass an explicit `addon` path; the ChatGPT extension loads the binding shipped beside the daemon binary, because its embedded server is a single bundled file. Conformance runs on real loopback sockets: event-loop responsiveness, abort of in-flight I/O, early-return transport release without cancellation, backpressure, process exit after settled calls, framing limits from the shared fixture, cursor resume, and typed refusals. BREAKING CHANGE: `ClientOptions.fetch` is removed. A Node >= 20 host needs the platform package for its OS/arch, or an explicit `addon` path. Error classes are unchanged but messages now come from the Rust client. Event names outside the canonical set, problem records with unknown or inconsistent fields, lone-CR line endings, a byte-order mark, malformed UTF-8, and a body ending inside a frame are protocol failures. `retry:` fields are ignored. The README documents the migration. Refs #4226 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScriptedAlchemy
enabled auto-merge (squash)
November 24, 2026 23:01
ScriptedAlchemy
disabled auto-merge
November 24, 2026 23:08
Preserve receipt-only workflow outcomes, reject invalid numeric controls, and release native stream I/O promptly. Ship and verify native platform packages and archive members, complete direct-install upgrades, and exercise lifecycle and installation regressions. Refresh the branch onto current master.
|
Reject unsafe integers across the native JSON boundary without rejecting canonical floating-point metrics. Verify real native HTTP, SSE and resume behavior. Install historical releases according to their immutable source contract, normalize Windows addon paths, and refuse updates while a Node host holds the binding. Exercise that refusal in Windows CI.
This branch has not been deployed
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.
Problem and issue scope
Refs #4226, and the SDK portion of the audit tracker #4230.
The Node SDK duplicated the Rust client's lifecycle and semantic rules. The
original PR also left native release delivery unwired, so publishing its
TypeScript facade would have produced an SDK without installable platform
packages and an offline extension without its required binding.
This PR moves the Node HTTP lifecycle onto the shared Rust protocol and adds
the native release, npm, installer, and updater paths needed to distribute it.
Issue #4226 should remain open until the full production-daemon installed-consumer checks,
supported-platform release builds, and npm package setup are complete. The unrelated work items tracked by #4230 remain independently
scoped.
Resulting behavior
use the same request preparation, envelope/problem admission, SSE framing,
cursor tracking, reconnect policy, and terminal classification. The duplicate
TypeScript HTTP/SSE implementation is removed. The daemon retains storage,
scheduling, authorization, and operation ownership.
AbortSignal interrupts in-flight transport I/O. Explicit iterator return or
throw interrupts an outstanding next call; a terminal frame closes its
response before the consumer asks for another event. Disposing a stream does
not request daemon-operation cancellation. Reads advance on consumer demand.
operations follow the canonical contracts. Rust TypedResponse.result is now
optional for valid receipt-only outcomes. Typed cancellation evidence is
decoded through its canonical type.
are refused before JSON can turn them into absent values. Existing sequence
number/bigint/decimal-string handling remains supported.
f64metrics; real HTTP tests cover both directions. Receipts, events, problems, and unknown integer fields are also guarded. Decimal-string and bigint resume cursors retain exact u64 query bytes.tracedecay.exeselected through PATH; PATHEXT is only applied to an unsuffixed executable name.Versioned migration
The TypeScript SDK is bumped from 0.15.0 to 0.16.0. The README documents the
removed custom fetch hook, strict framing and response admission, unchanged
public error classes with Rust-origin messages, explicit operation cancellation,
and iterator disposal. Applications need the platform package or an explicit
addon path. The Rust SDK README documents optional typed result payloads.
Native distribution
addon on each target from .github/release-targets.json: macOS arm64, Linux
x64/glibc, Linux arm64/glibc, and Windows x64.
build verifies complete platform coverage, package identity/version/platform
constraints, and exact addon bytes, then links optional dependencies at the
SDK version before packing the facade.
platform tarballs. Publication receives only digest-verified build artifacts
and the reviewed npm CLI; it publishes platform packages before the facade
through the existing protected OIDC environment.
daemon. Packaging verifies the extracted addon bytes and loads the extracted
binding. SPDX inventory records its checksum and Rust dependency closure
separately from the CLI. MCPB continues to launch the CLI directly.
The updater stages both before replacement and checks release identity when
completing an older executable-only updater's missing addon. Post-update
ChatGPT integration refresh performs that completion when needed.
resolution. Release recovery retains the tag's target roster and uses
compatible current runners.
Measured implementation and distribution cost
Measured against master fc80c47, using tracked
source lines including comments and blanks. Generated contracts, tests, and
unchanged SDK modules are excluded from this runtime comparison.
The runtime total grows by 344 lines (10.8%) while removing the duplicate
protocol authority. The new native package staging/verification script adds
133 lines separately. These counts do not establish a speed or binary-size
improvement.
Cargo.lock adds 11 external package identities and the local sdk-node crate,
with no removed package identities. The new native build requires a target
addon build and target load check. Distribution changes from one JavaScript
package to a facade plus one selected native platform package per consumer,
with four platform packages published per release. No consumer-side compile
or package install script is introduced. Optimized addon size and cold/warm
build timing are not yet measured in this session.
Verification performed for the follow-up changes
SDK unit tests passed all 10 cases. The addon measured 83,831,704 bytes in
the local k8-fastbuild profile (per-crate opt level 1 with assertions), which
is not a shipping-size measurement. The final fastbuild native package packed to 19,288,148 bytes; this is not an optimized shipping artifact or a comparable build-time benchmark.
npm install --offline --ignore-scripts, imported both public entry points, resolved the platform package without an addon override, and completed a real native HTTP request plus typed 401 error mapping. This is an installed-package smoke test; its package loader and native ABI were unchanged by the numeric follow-up, whose runtime is covered by the final native tests. The full production-daemon journey remains separate.including a 2 MiB addon, byte mismatch, missing package, and empty-addon
rejection.
handling and complete native roster planning.
missing-addon refusal, shared-component deduplication, and addon digest
verification.
diagnostics; its downloaded checksum was verified.
The runtime follow-up adds regressions for receipt-only results, non-cancellable
deadline receipts, malformed cancellation observations, numeric controls,
pending-read iterator disposal, terminal connection cleanup, and the live
typed-terminal fixture. The local native SDK results above cover the changed shared runtime; the Windows resolver follow-up has its own filesystem, typecheck, and embedded-artifact verification.
Final-head integration status
Current head:
cfc375d3eb008381cadb8c9554df655b48d41c28.a66593dpassed repository gates, feature gates, dashboard checks, benchmark harness self-tests, blocking Clippy, and all 181 Linux Bazel test targets (31 executed, the others cached). Its Windows build exposed an addon-rule analysis failure: the Rust shared library's default output set contains multiple files on Windows, so a single-input copy could not select the DLL.UnixListener::bindreturnedOperation not permitted. An independent probe confirmed thatsocket(AF_UNIX, SOCK_STREAM)creation itself is denied before binding or accessing a filesystem path, while file locking and loopback TCP succeeded. This workspace cannot run that Unix-socket-dependent journey. This attempt is not a passing installed-consumer result.Remaining release prerequisites and limits
using workflow release.yml and environment npm-tracedecay-sdk as documented
in docs/RELEASE-AUTOMATION.md. No npm publication was performed in this
repair session.
not changed by this PR. They do not yet deliver the addon. Manager-owned
incomplete installations receive a precise refusal rather than an
unmanaged write into the package manager's directory. Direct archives,
the shell installer, self-updates, and npm distribution are owned here.