Skip to content

feat(compaction): add dormant hard compaction planner#2838

Merged
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/v090-hard-compaction-planner
Jun 6, 2026
Merged

feat(compaction): add dormant hard compaction planner#2838
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/v090-hard-compaction-planner

Conversation

@Hmbown
Copy link
Copy Markdown
Owner

@Hmbown Hmbown commented Jun 6, 2026

Summary

  • add a default-disabled HardCompactionConfig and pure plan_hard_compaction helper
  • derive the hard-compaction plan from the existing plan_compaction machinery so recent tail, working-set pins, user-text fallback, and tool-call/result pair guarantees stay intact
  • add focused tests for too-short histories, recent-tail preservation, and the tool-pair boundary risk called out in review

Stewardship

Refs #2522. This harvests the safe planning layer from @HUQIANTAO's hard-compaction proposal without enabling hard compaction, adding user config, or adding a message-rewrite/LLM execution path. The broader runtime behavior remains deferred until tool-pair atomicity, anchors, working-set preservation, and cache/prefix metadata semantics are fully specified and tested.

Verification

  • cargo test -p codewhale-tui compaction --locked
  • cargo fmt --all
  • ./scripts/release/check-versions.sh
  • ./scripts/release/check-ohos-deps.sh
  • cargo clippy -p codewhale-tui --bin codewhale-tui --locked -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check
  • cargo check --workspace --all-features --locked

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Hmbown Hmbown merged commit d784f1e into codex/v0.9.0-stewardship Jun 6, 2026
2 checks passed
@Hmbown Hmbown deleted the codex/v090-hard-compaction-planner branch June 6, 2026 06:03
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a default-disabled hard-compaction planner that identifies the summarizable middle of a long conversation while preserving the recent tail, tool-call/result pairs, and working-set pinning. Feedback suggests optimizing the generation of preserved_indices in plan_hard_compaction by directly collecting soft_plan.pinned_indices instead of manually computing the complement of summarize_indices, which reduces complexity and avoids unnecessary allocations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +493 to +496
let summarized: BTreeSet<_> = soft_plan.summarize_indices.iter().copied().collect();
let preserved_indices = (0..messages.len())
.filter(|idx| !summarized.contains(idx))
.collect();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The preserved_indices are the exact complement of summarize_indices in the compaction plan, which is already computed and stored in soft_plan.pinned_indices. Instead of collecting summarize_indices into a temporary BTreeSet and performing a linear scan with .contains() checks, you can directly consume and collect soft_plan.pinned_indices into a Vec. This avoids unnecessary allocations and reduces the complexity from O(N log N) to O(N).

Suggested change
let summarized: BTreeSet<_> = soft_plan.summarize_indices.iter().copied().collect();
let preserved_indices = (0..messages.len())
.filter(|idx| !summarized.contains(idx))
.collect();
let preserved_indices = soft_plan.pinned_indices.into_iter().collect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant