Skip to content

Post-merge cleanup: PR #94 compaction feature follow-ups #97

@minpeter

Description

@minpeter

Context

Follow-up items identified during PR #94 (feat/minimal-agent-speculative-compaction) merge review. None of these are blocking — the PR passed all CI checks, 100/100 review threads resolved, and Oracle + automated review gave a GO. These are improvements to address in subsequent PRs.

Source PR: #94
Review rounds: 3 (100 threads resolved)
Reviewed by: Oracle (architecture), Explore agents (test coverage + code quality)


1. Test Coverage Gaps (Low Priority)

1a. Thin test files

  • packages/harness/src/memory-presets.test.ts — only 4 test cases. Verify all preset combinations (min/mid/max token budgets) are covered.
  • packages/cea/src/commands/compact.test.ts — only 3 test cases. Add CLI argument parsing edge cases and error handling paths.

1b. Missing regression tests (Oracle-recommended)

  • Stale speculative compaction: speculative completes but user/tool messages added mid-flight → verify stale discard
  • Per-turn cap reset: cap reached in turn N → notifyNewUserTurn() → auto/speculative allowed in turn N+1
  • Active-scope truncation invariant: collectToolResultEntries must only iterate post-summary messages
  • Headless speculative flow: onSpeculativeReady → applyReady → measureUsageAfterCompaction should apply exactly once

1c. End-to-end integration test

No cross-package E2E test for full compaction cycle with JSONL trajectory validation.


2. Code Quality Cleanup (Low Priority)

2a. Test debug output

8 console.log calls in compaction-integration.test.ts (lines 150, 233, 300, 386, 482, 589, 672, 675).

2b. Direct process.env access (pre-existing)

  • shell-detection.ts:54 reads process.env.SHELL
  • noninteractive-wrapper.ts:279 reads process.env.LC_ALL/LANG
    Fix: add to cea env.ts schema.

3. Architecture Concerns (Medium Priority)

3a. Public API surface over-exposure

harness index.ts exports internal helpers (*Core functions) and workflow types. Separate into public stable API vs internal types.

3b. Orchestrator responsibility creep

CompactionOrchestrator serves 5+ roles. Refactor into state machine/strategy if next feature adds more.

3c. notifyNewUserTurn() consistency

Add defensive warning if compaction attempted without prior notifyNewUserTurn().

3d. onApplied detail fields always zero

baseMessageCount/newMessageCount always 0. Fix or remove.


Checklist

  • 1a: Strengthen memory-presets and compact command tests
  • 1b: Add regression tests (stale-speculative, turn-cap-reset, active-scope-truncation, headless-flow)
  • 1c: Add cross-package E2E compaction test
  • 2a: Remove console.log from integration test
  • 2b: Route SHELL/LC_ALL/LANG through createEnv
  • 3a: Audit and reduce public exports in harness index.ts
  • 3b: Monitor orchestrator complexity
  • 3c: Add defensive guard for missing notifyNewUserTurn()
  • 3d: Fix or remove zero-value onApplied detail fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions