mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 05:12:11 +03:00
* perf: hoist Date.now, hoist hasActiveDeltaValue, avoid per-chunk buffer.split in SSE stream - Hoist to transform entry, remove 2 inner declarations that shadowed the outer one (stream.ts) - Hoist from inline closure to module-level function to avoid allocation per chunk (stream.ts) - Replace unconditional per chunk with -gated split to avoid allocating array when no embedded newline (stream.ts streamHelpers.ts) - Guard to avoid allocating when already at/above limit * fix: correct appendBoundedText slice offset when keep is zero * chore(ci): rebaseline stream.ts 2796->2801 for perf/p1-fixes Add _rebaseline_ entry documenting the +5 line growth from: -da7b1e2b2: hoist Date.now, hoist hasActiveDeltaValue, avoid per-chunk split -df89846cb: fix appendBoundedText slice offset when keep=0 These are irreducible optimizations at the stream dispatch chokepoint. * chore: trigger CI re-run * fix(#7066): bump stream.ts frozen baseline 2801->2802 (file grew +1 from parallel merges) * fix(ci): shrink stream.ts under the frozen file-size cap instead of rebaselining Two prior commits on this branch bumped config/quality/file-size-baseline.json (2796->2801->2802) to accommodate this PR's own +6 line growth in open-sse/utils/stream.ts, rather than fixing the cause. Per project policy the baseline gate is a ratchet — it may only shrink, never grow to paper over a regression. Reverted both bogus rebaseline edits (file-size-baseline.json now matches release/v3.8.49 exactly for this key) and instead extracted the two pure helper functions this PR added/touched (appendBoundedText, hasActiveDeltaValue) out of the god-file stream.ts into the existing sibling module streamHelpers.ts, mirroring the extraction precedent already documented in this baseline file. stream.ts now sits at 2778 lines (cap 2796); streamHelpers.ts grew to 487 lines, well under its own 800-line new-file cap. No behavior change — pure move. Verified via the existing tests/unit/streamHelpers.test.ts (20/20) and the full createSSEStream test set across 11 files (94/94), plus check:file-size, check:complexity, check:cognitive-complexity, check:test-discovery, check:any-budget:t11, and typecheck:core, all green. Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com> * test(sse): cover appendBoundedText slice(-0) trap and hasActiveDeltaValue Addresses the gemini-code-assist review finding on appendBoundedText. The bug it describes (`keep === 0` -> `current.slice(-0)` returns the WHOLE string, so the function returns current + next and blows past STREAM_SUMMARY_TEXT_LIMIT) was real, and was already fixed on this branch bydf89846c— but with zero test coverage guarding it. Both helpers were unexported internals of stream.ts and therefore untestable; the extraction into streamHelpers.ts made them reachable, so this adds the regression tests that lock the behavior in. 15 new tests. Verified as genuine guards, not decoration: temporarily restoring the buggy `keep = LIMIT > next.length ? LIMIT - next.length : 0` form makes exactly the two boundary tests fail ("next is exactly the limit" and "next is larger than the limit"); restoring the fix makes all 35 pass. Covers: - appendBoundedText: empty next, normal concat, tail-keep at overflow, window slide at limit, next === limit (the slice(-0) trap), next > limit, and a 40-iteration loop asserting the bound never breaks. - hasActiveDeltaValue: strings, null/undefined, empty/populated arrays and objects, nested recursion, and the number/boolean cases (0 and false are meaningful values, not absence). Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com> --------- Co-authored-by: oyi77 <oyi77@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
8.9 KiB
8.9 KiB