Skip to content

test: restore 32 e2e compaction tests + fix rehydrate partial_note regression#184

Merged
yishuiliunian merged 1 commit into
mainfrom
restore/e2e-compact-tests
May 26, 2026
Merged

test: restore 32 e2e compaction tests + fix rehydrate partial_note regression#184
yishuiliunian merged 1 commit into
mainfrom
restore/e2e-compact-tests

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Restores 32 e2e tests covering production compaction features whose tests were over-zealously dropped during dual-write retirement (commits 443dd444, 3d4111f4, ce82e401).
  • Migrates the seed pattern from the removed ContextStore::push_* / record_assistant_activity API to TurnStore-based seed via HarnessBuilder::messages + new tool_history helper.
  • Fixes a real regression uncovered by rehydrate_partial_failure_appends_model_visible_note: the partial-failure Text note was constructed in compact_rehydrate but never persisted because CompactionRehydrate only carried file pairs.

Restored coverage

File Tests Covers
microcompact_e2e_test.rs 5 idle scrub / noop on recent / non-scrubbable / all 10 tool types / disabled when idle=0
rehydrate_e2e_test.rs 9 real Read tool / empty / unreadable / partial / byte budget / stream event / partial note / pre-cancel / mid-cancel
compact_force_e2e_test.rs 5 reduces turns / manual-* label / preserves recent / tiny history / empty store
compact_instructions_e2e_test.rs 3 inject / omit / whitespace-only
compact_bare_summary_e2e_test.rs 4 LLM failure / outline / empty response / tagged extract
compact_phases_e2e_test.rs 2 full phase sequence / skip rehydrate when no touches
compact_hooks_e2e_test.rs 3 PreCompact manual / skip on tiny / auto
governance_bridge_test.rs 3 DataPlaneBridge sentinel / make_governance_feedback empty handling / multi-line text

Regression fix

CompactionRehydrate.partial_note: Option<String> is now persisted and projected in both:

  • loopal_provider_api::wire::turn_projection::project_compaction_rehydrate
  • loopal_provider::anthropic::request_turns::push_compaction_rehydrate

so the model sees [rehydrate partial: N of M ...] after partial-success rehydration.

Test-support additions

crates/loopal-test-support/src/tool_history.rs:

  • tool_history_turn() — builds an LlmCall(tool_calls) + ToolBatch Turn pair.
  • backdate_activity() — uses TurnTracker::with_wire_mut to retroactively age last_step_at (replaces removed record_assistant_activity).
  • reopen_for_test() — reopens the seeded Complete turn so post-seed append_step_record calls find an InProgress host.

Genuinely obsolete (NOT restored)

Original Reason
e2e_compact_partial_save_test (1) tested save_message failure; message_store is gone
e2e_compact_resume_test (2) tested messages.jsonl-anchored boundary survival; turns.jsonl is the only resume source
e2e_compact_test::auto_compact_on_large_context covered by compact_hooks::precompact_hook_fires_on_auto_compact
e2e_compact_edge_test::test_thinking_blocks_stripped covered by turn_degradation::strips_thinking_from_old_turns_only unit test

Test plan

  • CI passes (bazel build / test / clippy / rustfmt)
  • 32 newly-added e2e tests pass locally

…2e401

Restores 32 e2e tests covering production features whose tests were over-
zealously dropped during the dual-write retirement. Migrates seed pattern
from removed ContextStore::push_* / record_assistant_activity API to
TurnStore-based seed via HarnessBuilder::messages + new tool_history helper.

Restored coverage (new src/test-support helpers + agent_loop test files):

- microcompact_e2e (5): idle scrub / noop on recent / non-scrubbable / all
  10 supported tool types / disabled when idle=0
- rehydrate_e2e (9): real Read tool / empty touched / unreadable paths /
  partial success / total bytes budget / stream event / model-visible
  partial-failure note / pre-cancel / mid-cancel
- compact_force_e2e (5): reduces turns / manual-* strategy label /
  preserves most-recent user / short-circuits tiny history / empty store
- compact_instructions_e2e (3): custom instructions injected /
  omitted when None / whitespace-only treated as absent
- compact_bare_summary_e2e (4): falls back on LLM failure / deterministic
  outline / empty-response fallback / tagged summary extraction
- compact_phases_e2e (2): full phase sequence with rehydrate / skips
  rehydrate when no files touched
- compact_hooks_e2e (3): PreCompact fires on manual /compact / skipped
  on tiny history / fires on auto check_and_compact
- governance_bridge (3): DataPlaneBridge sentinel mock /
  make_governance_feedback empty handling / multi-line text

Also fixes a real regression revealed by rehydrate_partial_failure_appends_
model_visible_note: the partial-failure Text note ("rehydrate partial: N
of M ...") was constructed in compact_rehydrate's user message builder but
never persisted — CompactionRehydrate carried only file pairs, no note.
Add CompactionRehydrate.partial_note: Option<String> and project it in both
the wire-format anthropic emitter and the projection layer.

Test-support additions:
- tool_history::tool_history_turn — builds LlmCall(tool_calls) + ToolBatch
  Turn pair so tests can seed tool-result history without per-test
  boilerplate.
- tool_history::backdate_activity — uses TurnTracker::with_wire_mut to
  retroactively age last_step_at, replacing the removed
  record_assistant_activity API.
- tool_history::reopen_for_test — reopens the seeded Complete turn so
  rehydrate's append_step_record finds an InProgress host.

Skipped (genuinely obsolete — original API removed):
- e2e_compact_partial_save_test (1): tested save_message failure path;
  message_store is gone
- e2e_compact_resume_test (2): tested messages.jsonl-anchored compact
  boundary marker survival; turns.jsonl is the only resume source now
- e2e_compact_test::auto_compact_on_large_context: covered by new
  compact_hooks::precompact_hook_fires_on_auto_compact
- e2e_compact_edge_test::test_thinking_blocks_stripped: covered by
  turn_degradation::strips_thinking_from_old_turns_only unit test
@yishuiliunian yishuiliunian merged commit 3f5cf73 into main May 26, 2026
4 checks passed
@yishuiliunian yishuiliunian deleted the restore/e2e-compact-tests branch May 26, 2026 17:23
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