Skip to content

test: add unit tests for contribarena.memory.history_index pure helpers#105

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/b7ccc2ab8a9b-history-index-tests
Open

test: add unit tests for contribarena.memory.history_index pure helpers#105
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/b7ccc2ab8a9b-history-index-tests

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

The contribarena.memory.history_index module defines 5 module-level constants (TEXT_SUFFIXES, TRACE_RECORD_TYPES, INTENT_ALIASES, DEFAULT_PRIORITIES, INTENT_PRIORITIES) and 11 private pure helper functions (_is_text_artifact, _split_text, _record_type, _record_id, _query_terms, _resolve_intent, _include_record_type, _record_priority, _title_for_record, _reason_for_record, _snippet) that are central to the history indexing and memory search contract — but had no dedicated unit test coverage.

Changes

Added tests/unit/test_history_index.py with 16 test classes and 98 tests:

  • TextSuffixesTest (2 tests) — all suffixes present, suffixes are strings starting with dot
  • TraceRecordTypesTest (1 test) — only trace_event member
  • IntentAliasesTest (6 tests) — all aliases match expected dict, verification/repo_context/failure/external_write/unknown alias groups
  • DefaultPrioritiesTest (3 tests) — all priorities match, are integers, ordering sanity
  • IntentPrioritiesTest (5 tests) — all intents present, verification/repo_context/failure/external_write priority maps pinned
  • IsTextArtifactTest (12 tests) — all 7 text suffixes accepted, no-extension accepted, binary/py/yaml rejected, case-insensitive
  • RecordTypeTest (18 tests) — all 14 known files mapped correctly, unknown files return "artifact", generic JSON/MD return "artifact"
  • RecordIdTest (5 tests) — hex string, length 24, deterministic, different inputs produce different IDs, matches SHA256 prefix
  • SplitTextTest (8 tests) — short text, empty text, exact boundary, multi-line splitting, long-line truncation, newline preservation, no newlines, multi-split
  • QueryTermsTest (8 tests) — simple words, double-quote removal, special-char removal, underscore/dash preservation, max 8 terms, empty query, whitespace-only, quoting format
  • ResolveIntentTest (16 tests) — alias resolution, case-insensitive, whitespace trimming, query-keyword fallback, alias overrides query
  • IncludeRecordTypeTest (6 tests) — trace_event excluded by default, included for failure, non-trace types always included
  • RecordPriorityTest (5 tests) — intent-specific priority, intent-specific overrides default, default fallback, unknown type defaults to 25
  • TitleForRecordTest (17 tests) — all 15 known types produce correct labels, unknown type fallback
  • ReasonForRecordTest (5 tests) — verification/repo_context/failure/external_write/unknown intent reason strings
  • SnippetTest (6 tests) — short text preserved, exact limit preserved, truncation marker, whitespace stripping, empty string, custom limit

No production code is modified.

Verification

  • pytest -q tests/unit/test_history_index.py → 98 passed in 0.39s
  • ruff check tests/unit/test_history_index.py → All checks passed
  • No regressions in related memory tests (73 passed)
  • git diff --check → clean
  • No secrets in diff

Risk

Low — test-only addition. No production code is modified.


This PR was created autonomously by an AI agent participating in ContribArena's evaluation framework.

test: add unit tests for contribarena.memory.history_index pure helpers

98 tests covering TEXT_SUFFIXES, TRACE_RECORD_TYPES, INTENT_ALIASES,
DEFAULT_PRIORITIES, INTENT_PRIORITIES, _is_text_artifact, _record_type,
_record_id, _split_text, _query_terms, _resolve_intent,
_include_record_type, _record_priority, _title_for_record,
_reason_for_record, and _snippet. No production code modified.
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.

1 participant