Skip to content

fix(memory): task-aware context pruning critical fixes (#1851)#2066

Merged
bug-ops merged 4 commits intomainfrom
1851-task-aware-pruning
Mar 20, 2026
Merged

fix(memory): task-aware context pruning critical fixes (#1851)#2066
bug-ops merged 4 commits intomainfrom
1851-task-aware-pruning

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Fixes 5 critical issues in task-aware self-adaptive context pruning:

  • CRIT-1: Remove dead TaskAwareMig enum variant (was functionally identical to TaskAware). Backward compat via FromStr fallback with warning.
  • CRIT-2: Add MIG eviction ordering test (was missing test for prune_tool_outputs_mig).
  • CRIT-3: Enforce prune_protect_tokens in scored/MIG pruning paths (was missing protection).
  • CRIT-4: Document tokio::spawn limitation for background goal extraction. TODO(I3) for separate PR.
  • CRIT-5: Cap goal string length at 500 chars to prevent memory explosion.

Serde fix: Hand-written Deserialize impl routes through FromStr, enabling graceful fallback for config files with removed task_aware_mig variant.

Validation

  • Tests: 6093 → 6096 (+31 new, all pass)

    • 3 serde round-trip tests for backward compat
    • MIG eviction ordering test
    • prune_protect_tokens enforcement tests
  • Validators:

    • Perf ✅: No regressions, O(n²) MIG acceptable
    • Security ✅: No vulnerabilities
    • Impl-critic ✅: Serde blocker resolved, sound implementation
    • Tester ✅: All 6096 tests pass
    • Reviewer ✅: All CRIT fixes verified correct

Backward Compatibility

Users with strategy = "task_aware_mig" in config files now receive:

  1. A tracing::warn! message about the removal
  2. Automatic fallback to Reactive pruning strategy

Changes

  • crates/zeph-config/src/memory.rs: Remove TaskAwareMig variant, hand-written Deserialize impl
  • crates/zeph-core/src/agent/context/summarization.rs: Add MIG test, enforce prune_protect_tokens
  • src/cli.rs, src/init.rs: Remove task_aware_mig from CLI/wizard
  • config/default.toml, book/src/changelog.md: Update documentation
  • CHANGELOG.md: Document all 5 fixes and backward compat behavior

Pre-merge checks

  • cargo +nightly fmt --check
  • cargo clippy --workspace --features full -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins (6096 passed)

Resolves #1851.

Fixes 5 critical issues in task-aware self-adaptive context pruning:

1. CRIT-1: Remove dead TaskAwareMig enum variant (was routed to TaskAware,
   never called MIG scoring). Fallback via FromStr with warning for backward compat.

2. CRIT-2: Add MIG eviction ordering test to verify lowest-MIG blocks evicted first.

3. CRIT-3: Enforce prune_protect_tokens in scored/MIG pruning paths
   (was missing). Extract common helper prune_protection_boundary().

4. CRIT-4: Document tokio::spawn limitation for goal extraction
   (not cancelled on shutdown). TODO(I3) for separate PR.

5. CRIT-5: Cap goal string length at 500 chars to prevent memory explosion.

Serde fix: Hand-written Deserialize impl routes through FromStr,
enabling graceful fallback for config files with removed task_aware_mig variant.

Tests: +31 (6065 → 6096 total)
- 3 serde round-trip tests
- MIG eviction ordering test
- prune_protect_tokens enforcement tests (scored/MIG paths)
- CLI and init wizard tests

Backward compatibility: Users with strategy="task_aware_mig" in config
files now receive a warning and fallback to reactive pruning.

CHANGELOG updated. Docs updated (book/src/changelog.md).
@github-actions github-actions bot added bug Something isn't working size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate config Configuration file changes and removed size/L Large PR (201-500 lines) labels Mar 20, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 19:29
Main branch added Subgoal/SubgoalMig pruning strategies (#2022).
Our branch removed TaskAwareMig variant (dead code) and added hand-written Deserialize impl for graceful fallback.

This merge reapplies our CRIT-1 fixes (TaskAwareMig removal + task_aware_mig fallback)
while keeping the new Subgoal variants from main.

Changes:
- Removed TaskAwareMig variant reference (pruning_strategy was dead code)
- Added hand-written Deserialize impl routing through FromStr
- Added task_aware_mig → Reactive fallback with warning in FromStr
- Added 3 serde round-trip tests for backward compat
- Updated init.rs wizard to remove task_aware_mig option
- Updated summarization.rs match statement to remove TaskAwareMig arm

All tests pass, build clean.
@github-actions github-actions bot added the size/L Large PR (201-500 lines) label Mar 20, 2026
bug-ops added 2 commits March 20, 2026 20:49
…undary

The prune_protection_boundary() helper is only used in feature-gated code
(prune_tool_outputs_scored and prune_tool_outputs_mig). When building with
features that don't include context-compression (server, chat, ide), the
function was unreachable and caused a compiler error.

Fixes Bundle Check failures for server, chat, ide bundles on PR #2066.
@bug-ops bug-ops merged commit bc1dd9c into main Mar 20, 2026
29 checks passed
@bug-ops bug-ops deleted the 1851-task-aware-pruning branch March 20, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(context): task-aware self-adaptive context pruning (SWE-Pruner)

1 participant