Skip to content

fix(runtime): round 45 runtime and JNI findings - #543

Merged
owjs3901 merged 2 commits into
mainfrom
fix/runtime-round45
Nov 28, 2026
Merged

owjs3901 merged 2 commits into
mainfrom
fix/runtime-round45

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Round 45 runtime / core / JNI findings

Fixed

  • R45-IP0-M1 (MED), legacy direct-write never drains an event stream. finish_direct_write (behind dispatch_into, dispatch_into_async(_borrowed), vespera_dispatch_into and JNI dispatchDirect0) now answers a text/event-stream response (any status) with a bounded 500 wire (EVENT_STREAM_LEGACY_MSG) without polling its body. This also removes the 422 prefetch wait for an SSE body. Trade-off: a finite SSE that used to fit the caller's buffer is now refused on the legacy API; the resumable tail (dispatch_into_async_borrowed_resumable, DirectStash, streaming modes) is unchanged. Documented in vespera.h (vespera_dispatch_into), the dispatch_into_async / dispatch_into_async_borrowed docs and the ffi doc. Note for the docs fixer: the AGENTS.md C ABI row is not touched here.
    • Tests: legacy_event_stream_is_refused_without_draining (plain and with parameters) and legacy_event_stream_422_is_refused_without_the_prefetch, both over never-ending bodies under a 5 s timeout (they hang without the fix).
  • R45-CJ2-L1 (LOW, round-44 regression), repeated keys accepted again. inline_only_serde! buffered into serde_json::Value, whose map insert keeps the last duplicate. It now buffers through StrictValue, a visitor that errors duplicate field at every depth, returns the same Value otherwise. Covers Operation, MediaType, Encoding, Parameter, Header, Example, RequestBody, Response and SecurityScheme.
    • Tests: inline_only_types_refuse_a_repeated_key (nine types plus a nested duplicate), strict_value_matches_serde_json_value, strict_value_takes_every_visitor_method, strict_value_refuses_a_nested_repeated_key.
  • R45-CJ2-L2 (LOW), $ref in a callback map read as an expression. skip_callback_extension_keys (used by Operation::callbacks and Components::callbacks) refuses a $ref key, bare, with siblings, string or object value, with the Callback-flavoured Reference Object error.
    • Tests: callback_reference_key_is_refused_on_load (three cases).
  • R45-CJ0-L1+L2 (LOW), reflected part names missed format controls. needs_escape now escapes the Cf / Zl / Zp characters that reorder, hide or join text: soft hyphen, U+0600..0605, U+061C, U+06DD, U+070F, U+0890/0891, U+08E2, U+180E, U+2028..202E, U+2060..206F, U+FEFF, U+FFF9..FFFB, the musical and tag controls. The list is hand-written (no table dependency); it does not enumerate every Cf code point of every Unicode version.
    • Tests: five new reflected_field_name_is_bounded_and_printable cases (ALM, MVS, word joiner / invisible plus, BOM / interlinear anchor, soft hyphen / tag character).
  • R45-CJ0-L3 (LOW, doc). multipart/mod.rs no longer says "zero-dependency".
  • R45-CJ3-L2 (LOW, latent). dispatch_resumable (dispatchResumable0) zeroes the handle area (min(len, 9) bytes) on the undersized-buffer answer, like write_error_to_out. Test extends resumable_dispatch_never_reruns_a_handler (1023-byte and 4-byte buffers).
  • R45-IP0-L1 (LOW, comment). The two dispatch.rs comments that said header_value_from_owner falls back to from_str now describe the Latin-1 path for non-ASCII values.

Refuted / not changed

  • R45-CJ3-L1 (LOW), JNI streaming aborts drop the Java cause. Refuted for this round, with reasoning. The abort is raised with ThrowNew(VesperaStreamAbortedException, msg), which has no cause parameter. Attaching the captured cause needs one of: (a) NewObject of a (String, Throwable) constructor, or (b) ThrowNew followed by exception_occurred → clear → call_method(initCause) → Throw. Both are outside what NativeImageMetadataTest accepts: its everyJniLookupCallSiteIsCoveredByAnExtractionRule allows only find_class, get_method_id, throw_new and call_method, so new_object and throw fail the test unless the extraction rules change. The fix also has to carry the captured Throwable (a Global) from the Tokio worker's closures (push, header consumer, pull) to the outer symbol through StreamingFlags, at five abort sites, and it would need a demo-app E2E test. Calling initCause while the abort is still pending is not allowed under JNI's pending-exception rules, so the cause cannot be attached in place. The recipe is ready if the owners accept an extraction rule for Env::throw in NativeImageMetadataTest (a follow-up); this round's scope excludes that test file.

Not changed (also for the record)

  • Legacy dispatch_into still drains a non-SSE body of unknown length to count its size, bounded by max_buffered_response_bytes in bytes, not in time; that is the legacy API's documented contract.

Verification

  • cargo fmt --all -- --check clean.
  • cargo clippy -p {vespera_core,vespera_inprocess,vespera_jni,vespera} --all-targets --all-features -- -D warnings clean.
  • cargo test: vespera_core (all), vespera (lib, validated_extractor, jni_validation), vespera_inprocess --all-features (all targets), vespera_jni --lib (59).
  • No new JNI lookups; jni-config.json and the Java sources are unchanged, so the bridge and E2E suites were not run.
  • .changepacks/changepack_log_runtime_round45.json lists the seven packages at Patch.

🤖 Generated with Claude Code

owjs3901 and others added 2 commits November 28, 2026 13:33
- Legacy direct-write tail (dispatch_into, vespera_dispatch_into,
  dispatchDirect0) refuses a text/event-stream response with a bounded
  500 instead of draining a stream that may never end; the body is not
  polled. Documented in vespera.h, dispatch_into and the ffi docs.
- inline_only_serde! reads its object through a duplicate-rejecting
  visitor again (Operation, MediaType, Encoding, Parameter, Header,
  Example, RequestBody, Response, SecurityScheme): a repeated key is
  "duplicate field" as the derive reports it; accepted input is unchanged.
- A $ref key in a callback map is refused (bare, with siblings, string or
  object value) instead of loading as an empty Path Item.
- Multipart part-name echo escapes the Arabic letter mark, Mongolian vowel
  separator, word joiner, BOM and the other Cf format controls; the module
  doc no longer claims zero dependencies.
- Resumable DIRECT dispatch into an undersized out buffer zeroes the
  stash handle area like the error-wire path.
- Comment fix: header_value_from_owner's non-ASCII Latin-1 path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ey paths

The duplicate-key check is a plain contains_key + insert, so the arm lines
that the match on Entry left uncovered in CI's collapsed layout are gone.
expecting is executed through a type-mismatch error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@owjs3901
owjs3901 merged commit 859764e into main Nov 28, 2026
27 of 28 checks passed
@owjs3901
owjs3901 deleted the fix/runtime-round45 branch November 28, 2026 05:51
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