test: cover core utils/services + fix population-sizing bug (closes #26)#33
Merged
Conversation
Adds meaningful unit tests for previously untested core code and fixes a correctness bug the tests surfaced. Tests (42 new cases): - text_processor: whitespace normalisation, chunking, stats. - file_parser: chunking edge cases, txt/markdown extraction, encoding fallback, unsupported/missing files, multi-file merge with failures. - archetype_library: definition integrity, exact-count expansion, sequential ids, seed product-context injection, activity-config + map round-trip. - report_agent: tool-call parsing/validation (XML, bare JSON, trailing JSON, key normalisation) exercised via __new__ to skip the heavy LLM/Zep init. Bug fix (surfaced by the new tests): - expand_archetypes() forced >=1 agent per archetype, so for populations smaller than the 19 archetypes it overshot the requested total and computed negative intermediate counts (e.g. 3 -> 18 agents, 25 -> 26). Replace with a largest-remainder _distribute_population() that sums to exactly total_agents with no negatives. Also carries the stale _classify_batch mock fix so the suite is green on main (same one-line change as #30). CI (.github/workflows/launch-checks.yml) already runs backend/tests, so these run automatically. Co-Authored-By: PRATHAMESH75 <prathamesh290504@gmail.com>
pyproject declares flask-limiter but uv.lock never included it, so CI's `uv sync --frozen` silently skipped it and every test failed at conftest import with `ModuleNotFoundError: No module named 'flask_limiter'`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #26. Adds meaningful unit tests for previously untested core code — and fixes a real correctness bug the new tests surfaced. Branches off
main(independent of the stacked LLM-infra PRs #30/#31/#32).Tests added (42 cases)
text_processor— whitespace normalisation, chunking, stats.file_parser— chunking edge cases, txt/markdown extraction, non-UTF-8 encoding fallback, unsupported/missing-file errors, multi-file merge that tolerates failures.archetype_library— definition-integrity (required keys, ordered ranges, plausible population split), exact-count expansion, sequential ids, seed product-context injection, activity-config + map round-trip.report_agent— tool-call parsing/validation (XML<tool_call>, bare JSON, trailing JSON after reasoning text,tool/params→name/parametersnormalisation), exercised via__new__to avoid the heavy LLM/Zep init.Bug fix (found by the tests) 🐞
expand_archetypes()forcedmax(1, …)agents per archetype. For populations smaller than the 19 archetypes this overshot the requested total and produced negative intermediate counts:Replaced with a largest-remainder
_distribute_population()that sums to exactlytotal_agentswith no negatives. (Relevant to #24's configurable population sizing.)Notes
_classify_batchmock fix so the suite is green onmain— same change as fix: shared LLM output guardrail layer (closes #17) #30; harmless if both merge..github/workflows/launch-checks.yml) already runsbackend/tests, so these execute automatically. 47 passed locally.🤖 Generated with Claude Code