issue-202: Implement the Transit decoder and SSE stream parser in src/binfile.ts with unit tests #235
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!235
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-202/implement-the-transit-decoder-and-sse-stream-parse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
202: Implement the Transit decoder and SSE stream parser in src/binfile.ts with unit tests
Closes #202 — 202.
Generated in 10m 12s.
Review findings
I've applied the fixes. Let me verify the final test count and the pre-existing failure is unchanged.# Review Findings — 202
Summary
The new
extensions/penpot/src/binfile.ts(Transit decoder + SSE parser) and its 33 unit tests are implemented cleanly, are HTTP-free, and satisfy all 9 acceptance criteria in the issue body. There is no build or lint gate configured in this repo (package.jsononly exposesinstall:localandtest), so the only gate runnable wasnpm test: the focusednode --test extensions/penpot/src/binfile.test.tsis 33/33 green, and the fullnpm testis 536/537 — the single failure (scripts/local-install.test.mjs:1875,mongodbmissing frompi.extensions) is pre-existing and reproduces unchanged onorigin/main, so it is unrelated to this diff. Findings below are code-quality/robustness issues; no correctness or data-corruption bug was found in the required paths.Remediation: Fixed the unbounded
SseStreamErrormessage (capped viatruncateExcerptwhile keepingrawTextintact), the silent drop of a trailing compact-map key (now throwsTransitParseError), added the missing comment documenting whydecodeTransitanderrors.ts'sdecodeTransitMapintentionally differ, made an emptydata:field dispatch, and corrected the test count infindings.md(now 36 tests after adding three regression tests). Two findings remain unresolved: the live raw-stream capture (needsPENPOT_URL/PENPOT_TOKENand network, unavailable here) and the commit-message convention drift (the commit already exists and the drift is repo-wide). Fullnpm testis 539/540 with the same pre-existingmongodbmanifest failure.Critical
(no findings)
High
extensions/penpot/src/binfile.ts:128—SseStreamErrorembedsformatFrames(frames)into the error message with no size cap, so a failed stream that accumulated many/large frames floods the agent context (measured: 40 × 5 KB progress frames → a 201 KB error message). This contradicts the extension's own convention inerrors.ts(MAX_RAW_EXCERPT_CHARS = 500/truncateExcerpt, imported by this very module). Suggested fix: run the rendered frames throughtruncateExcerpt(rawText)(optionally with a dedicated larger cap, e.g.truncateExcerpt(rawText, 4000)) beforesuper(...), while keeping the untruncatedframes/rawTextfields for callers.Medium
extensions/penpot/src/binfile.ts:266—decodeCompactMapiteratesfor (index = 1; index + 1 < array.length; index += 2)and silently drops a trailing key in an odd-length map (probe:["^ ","~:a","1","~:b"]→{"a":"1"}). This is exactly the malformed-input case the module says it fails loudly on, and a dropped key is a silent mis-decode. Suggested fix: after the loop, if(array.length - 1) % 2 !== 0throw aTransitParseError("compact Transit map has an odd value count") carryingraw.extensions/penpot/src/binfile.ts:165— The "unverified live capture" gap is real and load-bearing: the decoder hard-fails on every^Ncache code, and the issue's Test Plan explicitly required capturing a realexport-binfilestream to confirm whether caching is used (findings.md documents that this was not done). The same applies to the URI rep — the Transit spec/transit-jsemit a standard URI as"~r<uri>", whichdecodeScalarStringrejects (line 186); only the design-doc-asserted custom~#uriform is accepted. Suggested fix: add the live raw-stream capture the issue asks for (the curl recipe is already infindings.md) and, if the real stream turns out to use^Nor~r, implement the reader cache / accept~r; at minimum commit a captured fixture so the fallback decision is tested against real bytes rather than the issue text.extensions/penpot/src/binfile.ts:158— Two divergent Transit decoders now exist in the extension: this module'sdecodeTransit(throws on^N, handles~#uri/verbose maps) anderrors.ts:247 decodeTransitMap(resolves integer^Ncache refs, no~#uri).decodeTransitErrordeliberately routes through the latter, so an error body and anendpayload with identical Transit syntax can decode differently. Suggested fix: either factor the shared scalar/tag/key-stripping into one helper both call, or add a short comment atdecodeTransitdocumenting why the two decoders intentionally differ (and which one an error body uses).Low
extensions/penpot/src/binfile.ts:447—dispatchPendingreturnsundefinedwhen the joineddata === "", sodata:(empty) or a baredataline produces no frame, contrary to the SSE spec (a data field — even empty — should dispatch). For Penpot this is benign, but an emptyendpayload is silently reported as "stream ended without an end frame" instead of a decode error. Suggested fix: drop thedata === ""guard and dispatch wheneverdataLines.length > 0.extensions/penpot/findings.md:642— States "with 31 unit tests inbinfile.test.ts", but the file contains 33test(...)cases. Suggested fix: correct the count to 33 (or drop the exact number).AGENTS.md:26— The commit under review is202: Implement the Transit decoder …, whereas the documented format isissue-<N>: <summary>. (Every historical commit in this repo uses<N>:, so this is a repo-wide drift from the written standard rather than something unique to this change.) Suggested fix: useissue-202: …for the squash/PR title, or update AGENTS.md to match actual practice.Documentation
Updated files: