feat: mark_block + batch cleanup for deferred block consolidation#13
Open
ranxianglei wants to merge 2 commits into
Open
feat: mark_block + batch cleanup for deferred block consolidation#13ranxianglei wants to merge 2 commits into
ranxianglei wants to merge 2 commits into
Conversation
Model can now mark blocks for deferred cleanup via mark_block tool (zero cache impact — block stays fully active). Marked blocks are merge-compressed together when context pressure rises, minimizing cache breaks. Three-tier batch cleanup in message transform pipeline: - Tier 1 (60%): nudge model about marked blocks - Tier 2 (75%): auto merge-compress all marked blocks into one - Tier 3 (90%): force merge ALL old-gen blocks (new fallback before GC) Existing GC retained as ultimate fallback at 100%. New mechanism is additive — no changes to existing GC or compression behavior. New files: lib/gc/merge.ts, lib/compress/mark-block.ts Modified: types, config, hooks, index, prompts, persistence, 10 test files
Review fixes (3 medium issues): - b0→b1 in all tool descriptions (BLOCK_REF_REGEX rejects b0) - Conditional nudge text for single-block case (no false auto-merge promise) - Selective markedForCleanup clearing (only merged IDs, preserves young marks) Tests (1 high issue): - tests/gc-merge.test.ts: 16 tests covering mergeMarkedBlocks (8) + runBatchCleanup (8) - Full suite: 402/402 pass (386 baseline + 16 new)
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
mark_blocktool + three-tier batch cleanup to ACP, separating block-cleanup intent from execution for minimum cache impact.Problem
ACP blocks are only-in-not-out — the model can compress/decompress but cannot delete. The only deletion mechanism is GC (age-based deactivation at
maxBlockAge=15), which fires regardless of context pressure and causes unnecessary cache misses + loss of important info (task_ids).Solution
mark_block(blockId)— model marks a block for deferred cleanup. Zero cache impact (block stays fully active, only sets internal flag).Three-tier batch cleanup in the message transform pipeline:
Existing GC retained as ultimate fallback at 100%. New mechanism is additive — no changes to existing behavior.
Cache impact
Files
New:
lib/gc/merge.ts(mergeMarkedBlocks + runBatchCleanup),lib/compress/mark-block.ts(mark_block/unmark_block tools)Modified: types, config, config-validation, hooks, index, prompts, persistence, state-utils, schema, 10 test files
Verification
npm run typecheck✅npm run build✅npm run test✅ (386/386, unchanged from baseline)devlog/2026-06-26_mark-block-batch-cleanup/(REQ.md + DESIGN.md + WORKLOG.md)