Skip to content

Round 41 runtime fixes: DIRECT stash keeps live entries - #518

Open
owjs3901 wants to merge 1 commit into
mainfrom
fix/runtime-round41
Open

owjs3901 wants to merge 1 commit into
mainfrom
fix/runtime-round41

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Round 41 runtime findings (one MEDIUM, five LOW). All seven were verified against the code before fixing; none was refuted.

R41-J2-MED1 (MEDIUM): DIRECT overflow stash evicted live responses

Stash::evict dropped the least recently stashed entries whenever the count (1024) or byte (256 MiB) budget was exceeded. An entry is stashed only after its handler ran, so an evicted, still-unredeemed response turned a correct response into a failed fetch0 / stream0 (a 500 on the Java side).

Change:

  • Only TTL-expired entries are swept (on every stash access, as before). A live entry is never evicted early.
  • A fresh overflow is refused only past the hard ceilings MAX_STASHED = 4096 entries and MAX_STASHED_BYTES = 1 GiB held (one response larger than the byte ceiling is kept alone when the stash is empty). A refused overflow answers a retryable 503 wire. A re-put over a live token is never refused.
  • DirectStash.java and StashedOverflowException.java javadoc document the retention and the fetch0 Integer.MIN_VALUE contract (unknown, expired, discarded or already redeemed while the runtime is live).

Residual, by design: at the hard ceiling a new overflow still gets a 503 instead of its response. Delivering it would need a Java-side change or a re-run of the handler, so I did not add one.

R41-IP1-L1 (LOW): try_on_shared_runtime accepted hooks after a failed build

try_on_shared_runtime now returns false when RUNTIME is settled as a failed build, so cron takes its "not scheduled" error path. start_runtime_for_hooks already returned false in that state (runtime() is None); its doc now says so. Test: child-process hooks_are_refused_after_a_failed_build.

Not covered: a hook queued while the build was still running, before it failed, is accepted and never flushed. Closing the queue on failure needs a branch no test can reach (the build does not fail in tests), which would break the 100% line gate, so I left it.

R41-CJ1-L1 (LOW): OpenApi::merge adopted an empty webhooks map

merge now uses non_empty_component_map(other.webhooks), as merge_component_map does. Test: merge_ignores_an_empty_webhooks_map_from_other.

R41-CJ2-L1, R41-IP0-L1, R41-I4-01 (LOW): doc and comment only

  • unescape_schema_name doc: invalid UTF-8 decodes to U+FFFD (lossy), not "kept as written".
  • RequestEnvelope::headers doc: a single value per name, last one wins (serde keeps the last entry); the type is not changed (semver).
  • tracing_instrumentation.rs comment: only the span app field withholds the raw client value; the WARN detail names it.

Verification

  • cargo test -p vespera_core: 332 passed.
  • cargo test -p vespera_inprocess --features runtime (lib and all integration tests), plus --features runtime,tracing --test tracing_instrumentation: all pass.
  • cargo test -p vespera_jni --lib: 58 passed. stash filter run three times: 10 passed each time.
  • cargo clippy --all-targets --all-features -- -D warnings on vespera_core, vespera_inprocess and vespera_jni: clean. cargo fmt --all applied.
  • stash_handle_protocol_and_eviction now fills to the hard ceiling and checks that no live entry is evicted; the old eviction code fails that check.
  • Changepack .changepacks/changepack_log_runtime_round41.json: all seven packages at Patch, ASCII note.
  • Java: javadoc only; not compiled here.

🤖 Generated with Claude Code

R41-J2-MED1: the DIRECT overflow stash evicted live, unredeemed responses
when the count (1024) or byte (256 MiB) budget was exceeded. The handler had
already run for them, so the later fetch0 / stream0 failed with a 500 for a
correct response. The stash now sweeps only TTL-expired entries; a fresh
overflow is refused with a retryable 503 only past the hard ceilings (4096
entries, 1 GiB held), and a re-put over a live token is never refused. The
DirectStash and StashedOverflowException javadoc document the retention and
the fetch0 Integer.MIN_VALUE contract.

R41-IP1-L1: try_on_shared_runtime refuses a hook once the shared runtime
build has failed, so cron takes its error path instead of reporting the job
accepted. Child-process test added.

R41-CJ1-L1: OpenApi::merge ignores an empty webhooks map from the other side
(as merge_component_map does). Test added.

R41-CJ2-L1, R41-IP0-L1, R41-I4-01: doc and comment corrections only
(unescape_schema_name lossy UTF-8, RequestEnvelope::headers single value,
tracing test comment).

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

This branch has not been deployed

No deployments
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