Skip to content

emrg: add unit tests for daemon token estimation and history serialization helpers - #128

Merged
argszero merged 1 commit into
masterfrom
feature/daemon-token-estimation-tests
Jul 22, 2026
Merged

emrg: add unit tests for daemon token estimation and history serialization helpers#128
argszero merged 1 commit into
masterfrom
feature/daemon-token-estimation-tests

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Adds 22 new unit tests for daemon's pure-function helpers that were previously untested:

FunctionTestsWhat's covered
_count_chars_for_tokens5Pure ASCII, pure CJK, mixed, empty, Kana
_estimate_tokens4Empty list, single message, tool_calls, multiple messages
_estimate_single3With content, empty content, non-string content
_records_to_text6Empty, message, tool_call, tool_result (500-char truncation), summary, mixed
_truncate_record4Short pass-through, long truncation, exact boundary, field preservation

All tests are pure-function, no mocking needed. From 15 tests → 37 tests in test_daemon.py.

Why

These functions are critical for the auto-compact flow — token overestimation causes premature compaction, underestimation causes context overflow. Having tests ensures future refactoring (tasks.yml migration) won't silently break token estimation.

Verification

319 passed in 0.63s

…ation helpers
Covers _count_chars_for_tokens (CJK/ASCII/mixed/Kana/empty),
_estimate_tokens (single/multi/tool_calls), _estimate_single,
_records_to_text (all 4 record types), and _truncate_record
(boundary/preservation). 22 new tests, all pure-function,
no mocking needed.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #4

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #4 (37 tests pass, good daemon + scheduler coverage)

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #5 (daemon tests solid, token estimation accurate)

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle #6 (389 pass, clean diff after rebase)

@argszero
argszero merged commit 75ced6e into masterJul 22, 2026
1 check passed
@argszero
argszero deleted the feature/daemon-token-estimation-tests branch July 28, 2026 11:59
Sign up for freeto 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

@argszero