Skip to content

Runtime bump, CI Machete move, and real response_size metric - #230

Merged
martsokha merged 2 commits into
mainfrom
chore/bump-runtime-move-machete
Aug 14, 2026
Merged

Runtime bump, CI Machete move, and real response_size metric#230
martsokha merged 2 commits into
mainfrom
chore/bump-runtime-move-machete

Conversation

@martsokha

Copy link
Copy Markdown
Member

Summary

Housekeeping across three fronts: bump the runtime engine, tidy CI to match runtime's layout, and fix a long-standing metrics inaccuracy.

Runtime bump

Bump the nvisy-engine / runtime git dep to latest main (bd96ed93e805a7). No code changes required — check, clippy, and tests all pass against the new revision.

CI: move Machete from Security → Build

The unused-dependency check (cargo-machete) now lives in the Build workflow alongside the other build-quality gates (fmt, clippy, docs), matching the runtime repo's layout, instead of sitting in the Security workflow next to cargo-deny and secret scanning. Security keeps deny and the secret scan.

Fix: response_size metric was always 0

The metrics middleware read response_size from the response's Content-Length header, but axum wraps handler responses in a streaming body that carries no such header at the point the middleware runs — so every response logged response_size=0, even a 200 JSON one.

Add CountingBody, an http_body::Body wrapper that tallies data-frame bytes as they stream (never buffers) and fires a callback with the total at end-of-stream, or on early drop (client disconnect). The metrics middleware wraps the response body and emits the "request completed" line — now with the real byte count — from that callback. Correct for JSON, file/audit downloads, and SSE streams alike.

request_size is unchanged (the client's Content-Length is already correct for request bodies; 0 for bodyless GETs).

Behavior note: for a streamed response the "request completed" log now fires when the body finishes (for a long-lived SSE connection, when it closes) rather than at handler return — which is genuinely when the response completes.

Testing

Full gate green: cargo check, cargo clippy -D warnings, cargo test — all pass with the bumped runtime. cargo machete passes locally (the new http-body dep is used). Three unit tests cover CountingBody (completion count, empty body, early drop).

🤖 Generated with Claude Code

martsokha and others added 2 commits August 14, 2026 00:10
The metrics middleware read response_size from the response Content-Length
header, but axum wraps handler responses in a streaming body with no such
header at that point, so it was ~always 0. Add CountingBody, an http_body::Body
wrapper that tallies data-frame bytes as they stream (never buffers) and fires
a callback with the total at end-of-stream or on early drop. The metrics
middleware wraps the response body and logs "request completed" (with the real
response_size) from that callback. Works for JSON, downloads, and SSE alike;
request_size is unchanged (Content-Length is correct for request bodies).

Also bump the nvisy-engine/runtime git dep to latest main (bd96ed9 -> 3e805a7).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Match the runtime repo's layout: the unused-dependency check (cargo-machete)
belongs alongside the other build-quality gates (fmt, clippy, docs), not in the
Security workflow next to cargo-deny and secret scanning. Security keeps deny
and the secret scan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@martsokha martsokha added chore maintenance, dependency updates, code cleanup server API handlers, middleware, auth dependencies dependency updates and version bumps labels Aug 13, 2026
@martsokha martsokha self-assigned this Aug 13, 2026
@martsokha
martsokha merged commit 3f35e00 into main Aug 14, 2026
8 checks passed
@martsokha
martsokha deleted the chore/bump-runtime-move-machete branch August 14, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore maintenance, dependency updates, code cleanup dependencies dependency updates and version bumps server API handlers, middleware, auth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant