Skip to content

fix(serve): consolidate delegated transport and accounting fixes - #291

Merged
shuk777 merged 12 commits into
Edge0-AI:mainfrom
Afloat16:fix/consolidated-delegate-20261117
Nov 18, 2026
Merged

shuk777 merged 12 commits into
Edge0-AI:mainfrom
Afloat16:fix/consolidated-delegate-20261117

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What & why

This consolidates the delegated-serving changes requested in the theme-grouping review. It supersedes #254, #255, #260, #261, #263, #264, #272, #275, #276, and #278.

The branch combines the related transport, accounting, and child-process fixes:

  • Preserve Messages and Responses cache counts from their protocol usage objects, including explicit zero counts and the existing timing precedence.
  • Retain protocol errors delivered inside HTTP-200 streams in the request/status records.
  • Validate nonnegative integer token counts before conversion and reject overflowing aggregate input counts.
  • Decode complete SSE events, including multiline data, comments, fragmented input, and LF/CRLF/CR line endings, for accounting and delegated chat.
  • Reject malformed or out-of-range memory telemetry before converting megabytes to signed byte counts.
  • Validate the announced ready port before conversion and reject invalid values without leaving a child process.
  • Forward Retry-After from delegated generation, token-counting, and metrics responses.
  • Avoid ancestor symlink cycles during delegated directory inspection while retaining ordinary acyclic aliases.
  • Apply producer backpressure to the SSE relay queue and wake blocked producers during cancellation. The queue bound is 256 KiB plus one receive chunk.
  • Enforce the remaining readiness budget while reading HTTP health responses, including delayed headers and continuously dripping bodies.

Integration

The branch starts from bc2dc409d420097b4e864d511901180d7c2c6bac. The merge commit retains all ten original PR heads as parents, preserving their commit histories.

Shared fixture, status-accounting, and proxy changes were merged together. Earlier protocol/cache tests now use the common SSE decoder. An additional combined regression checks that multiline, fragmented protocol-error events still preserve their terminal failure and error-code fields.

Area

  • CLI / local server and delegated-engine integration

How was it tested?

The following checks were run on the initial combined tree (972250a2b276459993c2f73f1afb25c559097f06) on Linux:

  • Full CPU preset build: passed.
  • moe_test_strata_registry: passed, including the original numeric, cache, error, SSE, directory, and memory regressions plus the multiline protocol-error interaction.
  • Full L0/L1: 97 passed, 3 Vulkan tests skipped, 4 failures. The failures are moe_test_app_generation, moe_test_platform_memory, moe_test_ordered_json, and moe_test_template_tools; the same four were reproduced in the recorded upstream-base run. This local gate is not fully green.
  • Actual native-server loopback integration: all applicable cases passed. These cover byte-exact forwarding across Chat, Responses, and Messages; streamed/non-streamed error reporting; 32 retry-advice requests plus metrics; invalid ready ports; readiness timeouts; cache/status accounting; launch and shutdown; interrupted streams; and the combined proxy behavior.
  • The backpressure integration passed a paused-reader 64 MiB stream, byte/hash parity after resuming, graceful drain, cancellation, and a 2 MiB non-streaming JSON control.
  • Complete moe_test_chat_strata CTest suite: passed.
  • Changed Python integration files compile, and git diff --check passes.

Not run here: non-loopback authentication (no routable non-loopback interface), macOS-specific preparation, Windows runtime, GPU execution, or real-model acceptance.

Cancellation follow-up (3257874574adff92fbb14ce58ca5ce05f33afd6f)

The current-head macOS CPU CI run now passes: the full build, L0/L1 gate and both delegated-engine L2 suites succeeded on the PR merge ref containing this commit. The local checks below retain their documented platform limits.

Cancellation now publishes its flag under the same mutex used by the backpressured producer's condition-variable wait. This closes the window where a notification could arrive between checking the predicate and sleeping. Notification and client->stop() remain outside the lock. This is the only production change; the consolidated multiline protocol-error regression is unchanged.

A deterministic check using the production Forward structure observed blocked producers in 10/10 original runs and 0/10 corrected runs. The consolidated moe_test_strata_registry was rebuilt and passes, including the multiline/error-code regression. The complete chat-Strata suite and real TCP serve scenarios also pass, including the paused-reader 64 MiB stream, byte/hash parity, graceful drain, disconnect cancellation and the 2 MiB ordinary-body control. Non-loopback authentication encounters OSError: [Errno 101] Network is unreachable here; the five following serve functions were run separately and pass.

The CLI binary was reused from the successful full CPU build of tree 57e76320eea81cc9daf4c09ac34f36c7c2896035: all production sources, headers, build configuration and integration harnesses match byte for byte. Only the expanded unit-test file differs and was rebuilt separately. The unrelated full L0/L1 gate was not repeated for this follow-up.

Checklist

  • Preserved all ten original fixes and regression cases.
  • Resolved overlapping code and fixture changes in one branch.
  • Ran the combined native build, unit gate, actual loopback HTTP tests, and delegated-chat suite.
  • Reported local failures and unavailable platform coverage explicitly.

Set the cancellation flag while holding the producer mutex so that abort cannot lose a notification between the wait predicate and blocking. Release the mutex before notifying and stopping the HTTP client.

@shuk777 shuk777 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — LGTM. Local Mac regression confirmed (unit + serve/chat strata L2, and a before/after SSE framing check). Merging.

@shuk777
shuk777 merged commit ad20b64 into Edge0-AI:main Nov 18, 2026
1 check passed
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.

2 participants