refactor(runtime-host): consolidate the private byte-limit helpers into the protocol codec #5887
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
hqhq1025
Summary
The last integration item from the #5038 read/write-amplification list:
turn.ts,message.tsandsession-continuity.tsin the runtime-host protocol each carried a byte-identical private copy ofrequireEncodedByteLimitalongside the shared implementation inprotocol/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 usesisInvalidFrame, which pins only the type and code). The stringify-failure andundefinedpaths 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 inpackages/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.jsfocused suite (covers call sites of all three files) | 88/88 before, 88/88 after ||
biome checkon the three changed files | exit 0 || Protocol epoch guard
--base upstream/main| exit 0 (epoch 200 unchanged,protocol/index.tsuntouched) ||
git diff --check| exit 0 ||
check:asf-headers| only pre-existing untracked.zcodeignorewarning; 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
isInvalidFramealready locks the retained behavior, and asserting the new wording would weld this PR's choice into tests)