Skip to content

Test the untested decision logic: tracker finalization, read-cache staleness, budget gating #36

Description

@egorfedorov

Problem

The highest-risk modules have zero tests on their core paths (per architecture audit):

  • tracker.js — session finalization, usefulness recompute, pattern/co-occurrence aggregation, auto-template creation. High risk, untested.
  • read-cache.jscheckStaleness() (token/file/time thresholds) and the big-file map-then-load nudge. High risk, untested.
  • budget.js — warning-emission gating at 50/70/85/95% and the compact recommendation.

Current tests/test.js covers pure helpers (estimateTokens, isRangeCovered, globToRegex, analyzePrompt, etc.) but not the stateful pipelines that actually decide what gets blocked and what "savings" are reported.

Why it matters

A product marketed as honest needs its decision logic under test, not just its formatters.

Proposal

  • Add fixture-based tests: feed a synthetic session → assert finalized usefulness/wasted classification + pattern aggregation.
  • Staleness: table-driven tests over (elapsedTokens, elapsedFiles, elapsedTime) → allow/block.
  • Budget gating: assert each threshold emits exactly once.
  • Refactor any process.exit(0) out of the testable core (see read-cache allow()), so tests don't terminate the runner.

Acceptance

  • tracker finalization, read-cache staleness, budget gating each covered.
  • npm test count meaningfully increases; no path calls process.exit during tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions