fix(compression): preserve polarity words and newlines in ultra heuristic - #13524
Merged
diegosouzapw merged 2 commits intoSep 15, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
…stic (diegosouzapw#13454) The ultra heuristic pruner scored polarity words (never, always, no, not, must, do) as stopwords (0.1) or short tokens (0.2), making them the first tokens pruned. This inverted instruction meaning: 'NEVER run rm -rf' → 'run rm -rf' 'must never be deleted' → 'must deleted' Also collapsed newlines via .replace(/\s{2,}/g, ' '), destroying bullet lists, headings, and code fences. Changes: - Remove polarity/modality words from STOPWORDS set (do, does, did, should, can, need, nor, always, never) - Add POLARITY_WORDS force-preserve set (score 1.0) for never, always, no, not, nor, must, do, can, should, need, and contractions - Only collapse spaces/tabs, not newlines, in pruneByScore output 8 tests in tests/unit/compression/ultra-heuristic-polarity.test.ts. Fixes diegosouzapw#13454
… for the intentional ultra trade-off
diegosouzapw
force-pushed
the
fix-13454-polarity-pruning
branch
from
September 15, 2026 02:44
e2c0f95 to
0fdd3d3
Compare
diegosouzapw
merged commit Sep 15, 2026
56fedf9
into
diegosouzapw:release/v3.8.51
2 of 7 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…stic (diegosouzapw#13524) The ultra heuristic no longer prunes polarity and modality words (`never`, `always`, `not`, `must`, `should`, `do`/`does`/`did`, contractions…). They now score 1.0 instead of the 0.1 stopword score, so "must never be deleted" can no longer collapse into "must deleted". It also collapses only runs of spaces and tabs, keeping the newlines that carry bullets, headings and fences (diegosouzapw#13454). Maintainer fixes: (1) the new test imported `../../open-sse/…` from `tests/unit/compression/`, which does not resolve, so it had never run. It now passes with the rest of the compression suite (1,526 cases). (2) Dropped the unused `STOPWORDS` import. (3) `check:compression-budget` flagged the expected trade-off: ultra tokens-per-task goes prose 92→97, tool-output 116→117, json 117→126, the cost of keeping meaning-bearing words and line structure. The baseline was refreshed with `--update`, which also records a pre-existing caveman tightening (129/127/160 → 119/114/136). (4) The branch also carried the unrelated `feat(sveltekit)` commit and the diegosouzapw#13523 commit, so it was reset to the release tip plus only this commit, authorship preserved. Validated in one consolidated batch of this series (37 PRs boarded together on `release/v3.8.51`): `typecheck:core`, `check:open-sse-typecheck` and `check:dashboard-typecheck` clean; ESLint clean on every changed file; file-size, complexity, cognitive-complexity, changelog-integrity, docs-counts, docs-sync and migration-numbering gates green (only the pre-existing `open-sse/utils/stream.ts` file-size red remains, inherited from the base); 3,743 focused `node:test` cases plus 34 vitest cases green. Thanks @KooshaPari!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The ultra heuristic pruner scored polarity words (
never,always,no,not,must,do) as stopwords (0.1) or short tokens (0.2), making them the first tokens pruned. This inverted instruction meaning:It also collapsed newlines via
replace(/\s{2,}/g, " "), destroying bullet lists, headings, and code fences.Changes
STOPWORDS: do, does, did, should, can, need, nor, always, never — they no longer score 0.1POLARITY_WORDSforce-preserve set (score 1.0): never, always, no, not, nor, must, do, can, should, need, and contractions (don't, can't, etc.)pruneByScorenow only collapses[ \t]{2,}not\s{2,}— bullet lists, headings, and code fences surviveTests
tests/unit/compression/ultra-heuristic-polarity.test.tsFixes #13454