← Back to Pull requests

refactor(runtime-host): consolidate the private byte-limit helpers into the protocol codec #5887

Closed
unknown closed this pull request without merging on Oct 10, 2026 10:53 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 14:50 UTC
Author

Summary

The last integration item from the #5038 read/write-amplification list: turn.ts, message.ts and session-continuity.ts in the runtime-host protocol each carried a byte-identical private copy of requireEncodedByteLimit alongside the shared implementation in protocol/codec.ts. All three now import the shared one; the private copies are deleted (3 files, +3/−36).

Observable change, disclosed: on the over-limit branch the protocol error message text changes from Invalid <label> to <label> exceeds byte limit (the codec's existing wording). The accept/reject decision, the error type (RuntimeHostProtocolError) and the code (invalid_frame) are unchanged. No test or consumer in the repo asserts the old wording (the one over-limit assertion uses isInvalidFrame, which pins only the type and code). The stringify-failure and undefined paths were already word-for-word identical in both versions.

Eight call sites were checked one by one (labels: Message content, Session message queue projection, queue.retract result, turn.interrupt result, subscription frame, Session continuity snapshot, subscription.open result, Session tool args preview) — all accept the shared signature as-is. The variant copy in packages/core/src/skill-invocation.ts (no label, UTF8.encode-based) is out of scope by dependency direction (core does not depend on runtime-host).

Verification

| Check | Result |
|---|---|
| Build chain core→storage→runtime→runtime-host (before + after) | exit 0 |
| protocol.test.js focused suite (covers call sites of all three files) | 88/88 before, 88/88 after |
| biome check on the three changed files | exit 0 |
| Protocol epoch guard --base upstream/main | exit 0 (epoch 200 unchanged, protocol/index.ts untouched) |
| git diff --check | exit 0 |
| check:asf-headers | only pre-existing untracked .zcodeignore warning; the three changed files are clean |

Honest boundaries: the message-text change was verified by static analysis (no consumer locks the old wording), not end-to-end client-side; spawn-heavy integration suites (message-coordinator, session-continuity-coordinator) were not run locally — the private functions had no logic change and call sites keep identical signatures, so the integration layer is not aware of them. Both left to CI.

Refs #5038

Generated-by: GLM-5.3-Flash (ZCode)

Checklist

  • I have read the Contributing Guide

  • The commit message follows the repository conventions

  • Tests cover the changed behavior (existing focused suite; no new assertions added — the pinning layer isInvalidFrame already locks the retained behavior, and asserting the new wording would weld this PR's choice into tests)
  • Diff: 350 lines (+262 / -88) across 4 files Reviewer: hqhq1025 Review duration: 14163m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 350 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5887"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.4% (MEDIUM) · Higher = larger blast radius
    42.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%
    Repository