feat: decompress tool range mode (startId/endId) — issue #14#73
Open
ranxianglei wants to merge 1 commit into
Open
feat: decompress tool range mode (startId/endId) — issue #14#73ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
Add optional startId/endId params to decompress schema as alternative to blockId. Range mode batch-restores every active block whose effectiveMessageIds overlaps the resolved message range in one call, eliminating the acp_status → decompress-per-block loop. Changes: - lib/compress/decompress.ts: schema gains optional startId/endId; handler refactored into resolveTargets dispatcher → single-block (unchanged logic) | range (new). Shared tail handles N targets. - lib/compress/decompress-logic.ts: new findActiveBlocksOverlappingMessages pure function. - tests/decompress-logic.test.ts: 11 new tests for overlap resolution. Boundary resolution reuses compress/search.ts (auto-swap reversed boundaries via Bug 34 fix, OOB clamping, recovery hints). Nested correctness: child effectiveMessageIds ⊇ consumed ancestor's, so both matched automatically — no separate parent-chain walk needed. Backward compatible: blockId path byte-identical to before; new fields are optional and mutually exclusive with blockId (handler rejects mixes). Tests: 586 pass, 1 pre-existing unrelated Bun limitation (prompts.test.ts nested test(), verified on master).
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
Adds optional
startId/endIdparams to thedecompresstool schema as an alternative toblockId. Range mode batch-restores every active block whoseeffectiveMessageIdsoverlaps the resolved message range in one call — eliminating theacp_status→ decompress-per-block loop.Mirrors Gitea PR #15.
Changes
lib/compress/decompress.ts— schema gains optionalstartId/endId; handler refactored intoresolveTargetsdispatcher →resolveSingleBlockTarget(unchanged) |resolveRangeTarget(new). Shared tail handles N targets (toFile gather, deactivate loop, pluralized report).lib/compress/decompress-logic.ts— new exportedfindActiveBlocksOverlappingMessages(messagesState, messageIdSet). Pure, O(blocks × effectiveIds), dedupes via Map, returns sorted by blockId.tests/decompress-logic.test.ts— 11 new tests covering empty set, no blocks, overlap match, inactive skip, partial overlap, multi-block sort, dedupe, disjoint, undefined effectiveIds, nested child-only, nested ancestor+child.devlog/2026-07-07_decompress-range-mode/— REQ.md, DESIGN.md, WORKLOG.md.Design highlights
compress/search.tsfor boundary resolution — inherits Bug 34 (auto-swap reversed boundaries), OOB clamping, and recovery hints for free.effectiveMessageIds⊇ consumed ancestor's effective IDs, so both are always matched when the range overlaps. Proof indevlog/2026-07-07_decompress-range-mode/DESIGN.md.blockIdpath byte-identical to before. New fields are optional;blockIdXOR (startIdANDendId) enforced at handler level with clear errors.Schema
Edge cases handled
blockId+startId/endIdmixed → mutual-exclusivity errorstartId/endId→ erroracp_statusVerification
npm run typecheck— PASSnpm run build— PASS (dist/index.js 357 KB)bun test tests/— 586 pass, 1 pre-existing fail (Bun limitation inprompts.test.ts:53— nestedtest()unsupported; verified on master via stash/pop)Follow-ups