test(ai): cover _TokenTracker, _synthesize_from_cache, _discover_directories (#70) #71
Loading…
Reference in a new issue
No description provided.
Delete branch "test/issue-70-tracker-synth-discover"
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?
Closes #70.
Second wave of pre-Phase-3 test coverage. The #55 round picked off the easy decision-logic helpers; this round covers the three highest-impact helpers that escaped the first sweep.
Three new test classes
TestTokenTrackerbudget_exceeded()useslast_input(most recent call's context size), NOT cumulative input. Cumulative would double-count because each turn'sinput_tokensalready includes the full message history. Tests assert: cumulative-input far above budget does NOT trip the gate whenlast_inputstays small;reset_loop()preserves grand totals; the boundary is strict>not>=.TestSynthesizeFromCache_run_synthesisexhausts itsmax_turns, which almost never happens in normal runs — exactly the kind of code that silently rots. Tests assert: empty cache returns the incomplete-message brief; single dir entry produces a markdown line; multi-entry detailed contains all entries; empty-summary entries are skipped; file entries alone do not satisfy (the function reads dir entries only).TestDiscoverDirectories.git/__pycache__/node_modules/*.egg-infoexcluded; custom--excludehonored; hidden dirs excluded by default;show_hidden=Trueincludes them but does not override the skip list.PLAN.md updates
Verification
tempfile.mkdtemp().Notable behavior the tests pin down
_TokenTracker.reset_loop()zeroeslast_input, not just the loop counters. The original issue draft assumedlast_inputwas preserved across resets — reading the actual code revealed it isn't. The tests now pin the real behavior.last_input == CONTEXT_BUDGETdoes NOT tripbudget_exceeded(). If anyone changes that to>=later, the test screams._synthesize_from_cachereads dir entries only. File entries are ignored entirely. The test makes this contract explicit.show_hidden=Truedoes not override the skip list..git/stays excluded even with hidden dirs visible — the skip filter and hidden filter are independent gates. Now pinned.