Repository navigation
test(transport): cover the protocol gaps later suites left, and floor src/transport - #296
Conversation
… src/transport Most of #79's criteria are now covered by suites written after it. This adds what nothing covered: the 10,000-character boundary, whitespace content, an unknown type and a ping timestamp in the validator; parseWsData and rejectSocket; an INVALID_FORMAT answer that leaves the socket open, over a real socket; the CORS default; and a debug-level run proving no log line carries a turn's content. Each test is cited from the statement it validates. src/transport/ gets its own coverage floor at the measured figures, and global is re-measured without those files. No covered count fell; the counts are recorded in the npm-release spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Lore is reviewing this PR — 27c96faa-8038-424d-ac46-2607a1be7f87. Submit a review that requests changes to have Lore push a fix for it. Comment |
🔍 Lore Spec Impact — advisoryThis PR touches 42 statement(s) across 6 spec(s), and 16 of them have validating tests this PR does not change. Session Resume · 19 statement(s)
Reading the requested id
validated by Reading the requested id
validated by Reading the requested id
validated by Reading the requested id
validated by Continuing the latest session
validated by Opt-in only its test links changed — the statement text itself is unchanged
validated by Rejoining a conversation only its test links changed — the statement text itself is unchanged
validated by Rejoining a conversation only its test links changed — the statement text itself is unchanged
validated by The store decides what is live only its test links changed — the statement text itself is unchanged
validated by Continuing the latest session only its test links changed — the statement text itself is unchanged
validated by …and 11 more statement(s). Weaker signals (21) — linked by a spec, not proven by a test runHAL Engine chat routes · 10 statement(s)
How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by How the routes are mounted
validated by …and 11 more statement(s). 3 changed statement(s) had no validating test, so no coverage broke. 33 new statement(s) have no test link yet. Deterministic · graph @ |
There was a problem hiding this comment.
Lore review — Approved
Covers the remaining transport protocol gaps from #79 with spec-linked tests and adds the measured coverage floor for src/transport/.
Must fix (0) · Consider (0) · Nits (0)
Reviewed by gemini-4-argon
Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.
Posted by floor, visit b9438844-146d-4482-9a71-692cf532a8e7.
There was a problem hiding this comment.
Lore review — Approved
Clean merge of origin/main (body-parser 2.4.0 lockfile update) with all CI checks passing.
Must fix (0) · Consider (0) · Nits (0)
Reviewed by gemini-4-argon
Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.
Posted by floor, visit a0acfedf-070f-4095-b760-9b1332d1394c.
Why
#79 asked for the transport layer to be tested against the shipped protocol docs. Since it was written in September, later work has covered most of it: the session-resume, credential-binding, upgrade-failure, single-terminal-frame and suppression suites all test what it lists. This PR maps every criterion to the test that now covers it, adds tests for the ones nothing covered, and gives
src/transport/its own coverage floor.What Changed
New tests, each cited from the statement it validates:
ws/validation.test.ts: 10,000 characters accepted and 10,001 refused with the limit named; three spaces refused as empty;{type: 'nope'}refused with its type named; a ping with a missing or text timestamp refused, and a numeric one passed through unchanged.ws/helpers.test.ts:parseWsDatareads JSON from text and from bytes, and reads an unterminated{asnull.rejectSocketwrites exactlyHTTP/1.1 401 Unauthorized\r\n\r\nto a realDuplexand destroys it.invalidFrame.test.ts, new: over a real socket, a frame that is not JSON gets{type: 'error', code: 'INVALID_FORMAT', message: 'Invalid JSON'}, and a ping on the same socket still gets its pong.createApp.test.ts: with neithercorsOriginnorCORS_ORIGIN, a response allowshttp://localhost:3000with credentials.contentFreeLogs.test.ts, new, at the root because it drivescreateHalEngine: withLOG_LEVEL=debugset before the logger loads and the console captured, a turn with a tool call logscontentLength: 32for a 32-character question. No line carries the question, the tool's argument or result, or the answer. Injecting a debug line with the question makes it fail.Spec statements:
hal-engine-websocket-protocol: the two content constraints in § 4.1 and the two validation lines in § 12 are now cited. New statements cover the ping timestamp, frame parsing, theINVALID_FORMATanswer and the bare HTTP status line before the handshake, plus a GDPR data-minimisation line for logs.hal-engine-architecture: the CORS default.hal-engine-session-resume: four citations moved down one line, becausehelpers.test.tsgained an import.Coverage:
jest.config.jsgains'src/transport/'at what it measures: 97.19% statements, 93.77% branches, 96.81% functions and 97.30% lines.globalis re-measured, because naming the path takes the transport files out of it. The re-measurement and the counts are recorded inhal-engine-npm-release§ Coverage floor.Decisions for the reviewer
These are deviations from the issue text.
global's percentages go down. The issue asks both to re-measureglobaland to lower no threshold, and both cannot hold in percentages. The files still inglobalmeasured 457/496 statements, 228/266 branches, 119/132 functions and 391/418 lines onmain, and 458, 228, 120 and 392 here. No count fell; the percentages fell because well-covered files left the group. AGENTS.md settles a change of measure on absolutes, and this follows that rule. The two new floors together are strictly tighter than the old one. The old global floor let the combined files fall to 1116 statements, 635 branches, 271 functions and 969 lines. The new floors require at least 1117, 635, 272 and 970, and hold transport and the rest separately, so a drop in one can no longer hide behind a rise in the other.sessionStore.deleteon every close was reversed by feat(session): stop erasing a conversation on socket close #116.sessionSurvivesClose.test.tspins the opposite.Authorizationtaking precedence over the subprotocol was replaced by the agree-or-refuse rule.credential.test.tsandhandshake.test.tspin it.helpers.test.tsandsessionResume.test.tscover.wsPath.test.tspins it.isValidWsPathalso takes two arguments now, not three.messageHandler.test.tsalready covers everything listed formessageHandler.characterization.test.ts: frame order, thinking, tool entries, suppression, error mapping, the hiddenAIErrormessage and the terminal frame. The real-port suites already covercreateServer.integration.test.ts:handshake,sessionResume,upgradeFailureandhistoryControlseach start a server on port 0, run a turn and stop it.connectionHandler.test.ts. The recording socket there cannot show that the connection stayed open; a pong on the same socket does.Already covered
send_messagerefusedvalidation.test.ts, rejects send_message?sessionId=abc-123on the pathhelpers.test.ts,wsPath.test.tscredential.test.ts,handshake.test.tsx-forwarded-hostbeatshostforwardHeaders.test.tsmalformedUpgrade.test.ts,upgradeFailure.test.ts,handshake.test.tsconnectedframeconnectionHandler.test.ts, which matches a UUIDv4 and the default message;connectExamplePrompts.test.tsstream_endafter suppressionmessageHandler.test.tsisStreaming: true, and a tool entry carrying itstoolNameandtoolInputsrc/testing/frames.test.ts, which compares the recordedthinkingThenToolframes field for field with a fresh run of the handler;messageHandler.test.tsalso asserts the tool fields under suppressionRATE_LIMITED,SERVER_ERROR, no thrown message in a frame, the terminal framemessageHandler.test.ts,errorMapping.test.tshandshake.test.ts,historyControls.test.tsand others; Jest runs without--forceExit, so a handle left open would hang the runAlternatives Considered
Writing the three files the issue names anyway. It would duplicate suites that exist, and
no-duplicate-coderefuses most of that duplication. Exporting module-private helpers for testing was ruled out by the issue itself.ADRs & Architecture
No source change. The log test sits at the root because the layering rule lets only the root reach
createHalEngine.Testing
npm run verifypasses: 1030 tests in 114 suites, coverage at the new floors, and every spec check.scripts/check-changelog.shfinds no shipped source changed. The Build chain check will fail until #295 lands, because of a body-parser advisory published on 23 October.Related Issues
Closes #79.
🤖 Generated with Claude Code