Pre-Phase-3 test coverage: _TokenTracker, _synthesize_from_cache, _discover_directories #70
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Three more pure-ish helpers in
ai.pywarrant unit coverage before Phase 3 lands. The #55 round picked off the easy decision-logic helpers; these three are the high-impact ones that escaped the first sweep.Targets
1.
_TokenTrackerclass (ai.py:94)Per-loop token accumulator. Has the
last_inputvs cumulative-totals distinction that #44 fixed and that the entire context budget reliability story rests on. If this regresses, the budget check silently stops triggering (or triggers spuriously) and there is no way to catch it from outside.Test cases:
record_usage()updateslast_input,loop_total,grand_totalcorrectlyreset_loop()zeroesloop_totalbut preservesgrand_totalandlast_inputbudget_exceeded()checkslast_inputagainstCONTEXT_BUDGET, not the cumulative sum (the load-bearing #44 fix)grand_totalacross resetslast_input == CONTEXT_BUDGET→ not exceeded (the gate is>, not>=)2.
_synthesize_from_cache()(synthesis fallback)Pure function that builds a brief + detailed report from cached file/dir entries when
_run_synthesisexhausts its max_turns. Last-resort path that fires almost never in normal runs and is therefore the kind of code that silently rots.Test cases:
3.
_discover_directories()(leaves-first walk + skip filter)Walks the filesystem, applies
_should_skip_dir, sorts leaves-first. The output drives the entire dir-loop iteration order. Leaves-first is the foundation of the cache reuse story (a directory's children must be summarized before the directory itself).Test cases:
a/b/c,a/d) → leaves come before parents.git/,__pycache__/,node_modules/,*.egg-info/are excluded--excludelist is honoredTest layout
Add three new test classes to
tests/test_ai_pure.py. Reuses the existing_make_manager()tempdir-cache helper andtempfile.mkdtemp()pattern.Acceptance criteria
tests/test_ai_pure.pycovers the three new helpersNotes
_TokenTrackeris the highest-priority of the three because the #44 fix is load-bearing for every Phase 3 feature that touches token accounting