Skip to content

feat(biome): add traceable article chunk context - #42

Merged
iihimanshuu merged 1 commit into
hiperhealth:mainfrom
iihimanshuu:feat/chunk-aware-context
Aug 23, 2026
Merged

iihimanshuu merged 1 commit into
hiperhealth:mainfrom
iihimanshuu:feat/chunk-aware-context

Conversation

@iihimanshuu

Copy link
Copy Markdown
Collaborator

Pull Request description

Complete the traceable context-output portion of chunk-aware retrieval.

Chunk-aware lexical retrieval, filtering, result limits, and provenance
resolution are already available on main. This PR adds the remaining
standalone context-generation APIs required by Issue #28.

This PR:

  • adds deterministic structured context for retrieved article chunks;
  • adds deterministic human-readable text context;
  • preserves retrieval order;
  • includes each matched chunk’s stable ID and zero-based index;
  • preserves the exact supplied chunk text;
  • includes the parent record ID, title, and review status;
  • includes deterministic relevance scores;
  • preserves resolved scientific-reference identifiers and canonical URLs;
  • documents empty structured and text context behavior;
  • validates result containers and individual chunk results;
  • exports both chunk-context functions through the public hphbiome API;
  • keeps existing record-level retrieval and context behavior unchanged;
  • adds focused tests using fictional, non-medical data.

Closes #28

How to test these changes

  • Run the focused context and chunk-retrieval tests:

    py -3.13 -m pytest tests/test_context.py tests/test_chunk_retrieval.py -q -p no:xonsh

  • Run the complete test suite:

    py -3.13 -m pytest --cov=hphbiome --cov=hphbiome_hiperhealth --cov-fail-under=92 --cov-report term-missing --no-cov-on-fail -p no:xonsh -q

  • Run Ruff:

    py -3.13 -m ruff check packages tests

  • Verify formatting:

    py -3.13 -m ruff format --check packages tests

  • Run mypy:

    py -3.13 -m mypy packages/hphbiome/src packages/hphbiome-hiperhealth/src

  • Run pre-commit against the changed files:

    py -3.13 -m pre_commit run --files packages/hphbiome/src/hphbiome/context.py packages/hphbiome/src/hphbiome/__init__.py tests/test_context.py --verbose

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

Additional information

The full test suite passes with 269 tests and 99.85% coverage.

No external dependency, HiperHealth integration change, medical claim, PHI,
semantic search, embedding, or retrieval-algorithm change is included.

Existing record-level retrieval and context APIs remain backward compatible.

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved

@iihimanshuu iihimanshuu self-assigned this Aug 23, 2026
@iihimanshuu
iihimanshuu merged commit 9d843f4 into hiperhealth:main Aug 23, 2026
16 checks passed
@iihimanshuu
iihimanshuu deleted the feat/chunk-aware-context branch August 23, 2026 19:04
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.

Add chunk-aware lexical retrieval and traceable context output

1 participant