Skip to content

test: Tier 1 behavioral test coverage + dead code cleanup - #23

Merged
ranxianglei merged 2 commits into
masterfrom
2026-06-27_test-coverage-hardening
Jun 27, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-06-27_test-coverage-hardening

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

Step 1 + Step 2 of the test coverage hardening iteration, preparing the behavioral spec foundation for the clean-room MIT rewrite.

Step 1: Dead Code Cleanup (commit f6d8b10)

  • Deleted 3 dead functions: sendUnifiedNotification (45 LOC), truncateExtractedSection (15 LOC), formatPruningResultForTool (16 LOC) — zero callers confirmed via dual-agent review
  • Unexported 6 internal-only symbols (no external importers)
  • Removed 3 commented-out debug log lines
  • Updated AGENTS.md test count (350→407, file count 22→31)

Step 2: Tier 1 Behavioral Tests (commit c39ef36)

7 new test files, 66 new tests covering 7 critical previously-untested modules:

File Tests Module
prune.test.ts 16 filterCompressedRanges, pruneToolOutputs/Inputs/Errors
reasoning-strip.test.ts 7 stripStaleMetadata
sync.test.ts 8 syncCompressionBlocks
protected-content.test.ts 14 extractProtectedPromptInfo, appendProtected*
persistence.test.ts 7 saveSessionState, loadSessionState
inject.test.ts 9 injectMessageIds, injectCompressNudges
pipeline.test.ts 5 prepareSession, finalizeSession

Total: 473 tests pass, 0 failures (was 407).

Dual-Agent Review

Both review passes APPROVED. Issues found and fixed:

  1. Config factories missing autoUpdate, summaryBuffer, batchCleanup — fixed
  2. Logger({ level: "error" }) should be Logger(false) — Logger takes boolean — fixed
  3. createSessionState(SID) called with nonexistent parameter — fixed
  4. SearchContext/SelectionResolution mocks had wrong field names — fixed
  5. ToolContext mock missing prompts field — fixed

Test plan

  • npm run test — 473 pass, 0 fail
  • Dual-agent review (§5.6 checklist) — both APPROVED
  • Devlog: devlog/2026-06-27_test-coverage-hardening/REQ.md + WORKLOG.md

Dead code cleanup (Phase 1 of test coverage hardening for MIT relicensing):

Deleted (never called anywhere):
- sendUnifiedNotification (lib/ui/notification.ts, 45 LOC)
- truncateExtractedSection (lib/ui/notification.ts, 15 LOC, cascade-dead)
- formatPruningResultForTool (lib/ui/utils.ts, 16 LOC)

Cleaned:
- 3 commented-out // logger.info debug lines (lib/state/state.ts)

Unexported (internal-only, no external importers):
- appendToToolPart (lib/messages/utils.ts)
- truncate (lib/ui/utils.ts)
- shortenPath (lib/ui/utils.ts)
- MESSAGE_REF_MAX_INDEX (lib/message-ids.ts)
- getConfigKeyPaths (lib/config-validation.ts)
- checkAutoUpdate (lib/update.ts)

Updated:
- AGENTS.md test count 350 -> 407, file count 22 -> 31

Verification: typecheck pass, 407/407 tests pass.
Dual-agent review: both APPROVED (dead code + unexport safety verified).
New test files covering previously untested core modules:
- tests/prune.test.ts (16 tests) — filterCompressedRanges, pruneToolOutputs/Inputs/Errors
- tests/reasoning-strip.test.ts (7 tests) — stripStaleMetadata
- tests/sync.test.ts (8 tests) — syncCompressionBlocks
- tests/protected-content.test.ts (14 tests) — extractProtectedPromptInfo, appendProtected*
- tests/persistence.test.ts (7 tests) — saveSessionState, loadSessionState round-trip
- tests/inject.test.ts (9 tests) — injectMessageIds, injectCompressNudges
- tests/pipeline.test.ts (5 tests) — prepareSession, finalizeSession

These tests serve as the behavioral spec for the clean-room MIT rewrite.
Dual-agent reviewed: all config factories complete, Logger usage corrected,
SearchContext/SelectionResolution mocks match actual interfaces.

Total: 473 tests pass (was 407).
@ranxianglei
ranxianglei merged commit 22498da into master Jun 27, 2026
3 checks passed
ranxianglei added a commit that referenced this pull request Jul 11, 2026
…heck

Two new E2E tests for issue #23:

1. 'nudge survives compress → restart → re-establishment → growth':
   Full lifecycle test — compress clears baseline, save/reload,
   re-establishment turn, save/reload again (verifies persistence),
   then growth turn must fire nudge. This test would have caught
   the baseline persistence bug before it shipped.

2. 'nudge recommendation content includes composition breakdown':
   Verifies that the injected suffix text contains 'Breakdown:',
   tool category, and compress guidance — ensuring the nudge
   actually delivers useful information to the model.

623 tests pass, 0 failures.
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