Skip to content

Increase test coverage for hook system context-bloating bottlenecks#30

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/increase-test-coverage-hook-system
Closed

Increase test coverage for hook system context-bloating bottlenecks#30
Copilot wants to merge 2 commits intomainfrom
copilot/increase-test-coverage-hook-system

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

The hook system injects output directly into Claude's context window, but key output-limiting paths (event log caps, file truncation, dep-graph guards, handoff summaries) had near-zero test coverage — making it hard to detect regressions that cause context bloat.

New: limits/limits_test.go (0% → 100%)

  • TruncateAtLineBoundary — within-budget no-op, truncation with custom/default suffix, clean line-boundary cut, zero/negative guard
  • AdaptiveDepth — depth 4→3→2 scaling across small/medium/large repo thresholds
  • HandoffBudgetForRepo — list-size budgets monotonically decrease with repo size

New tests in cmd/hooks_test.go (4.2% → 18.5%)

Test What it targets
TestGetLastSessionEvents 20-line cap on events.log, blank-line skipping, missing/empty file
TestShowLastSessionContext 5-file truncation (... and N more files), malformed line skip, REMOVE→"edited" fixup
TestShowSessionProgress Hub-edit counter surfacing risky churn; zero-hub label omission
TestGetHubInfoNoDeps Guard that returns nil when state has no dep graph, preventing expensive fallback scans
TestHookPreCompact hubs.txt creation, correct content, silent skip when no hubs
TestShowRecentHandoffSummary Nil safety, branch/changed-files/risk-file rendering

A shared writeWatchState helper sets up daemon state for tests that need watch.ReadState to return real data:

func writeWatchState(t *testing.T, root string, state watch.State) {
    // writes state.json + PID file so watch.ReadState returns the given state
}
Original prompt

Help me increase test coverage to help expose bottlenecks in hook system that's creating context bloating


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Increase test coverage for hook system Increase test coverage for hook system context-bloating bottlenecks Feb 27, 2026
@JordanCoin JordanCoin closed this Feb 28, 2026
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.

2 participants