Skip to content

test: cover core utils/services + fix population-sizing bug (closes #26)#33

Merged
PRATHAMESH75 merged 2 commits into
mainfrom
feat/26-core-service-tests
Jun 21, 2026
Merged

test: cover core utils/services + fix population-sizing bug (closes #26)#33
PRATHAMESH75 merged 2 commits into
mainfrom
feat/26-core-service-tests

Conversation

@PRATHAMESH75

Copy link
Copy Markdown
Owner

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/paramsname/parameters normalisation), exercised via __new__ to avoid the heavy LLM/Zep init.

Bug fix (found by the tests) 🐞

expand_archetypes() forced max(1, …) agents per archetype. For populations smaller than the 19 archetypes this overshot the requested total and produced negative intermediate counts:

requested before after
3 18 3
25 26 25
50 50 50

Replaced with a largest-remainder _distribute_population() that sums to exactly total_agents with no negatives. (Relevant to #24's configurable population sizing.)

Notes

  • Also carries the one-line stale _classify_batch mock fix so the suite is green on main — same change as fix: shared LLM output guardrail layer (closes #17) #30; harmless if both merge.
  • CI (.github/workflows/launch-checks.yml) already runs backend/tests, so these execute automatically. 47 passed locally.

🤖 Generated with Claude Code

PRATHAMESH75 and others added 2 commits June 20, 2026 19:50
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>
@PRATHAMESH75 PRATHAMESH75 merged commit 4ebd9ab into main Jun 21, 2026
2 checks passed
Sign up for free to 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.

Expand test coverage for core services

1 participant